From 1b84bf255482c01768c0206466ae69d7b2a64197 Mon Sep 17 00:00:00 2001 From: Hal Finkel Date: Mon, 5 Jan 2015 21:33:14 +0000 Subject: [PATCH] [PowerPC] Add a test for truncating a shifted load We now produce the desired code as noted in the README.txt file. Remove the README entry and add a regression test. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225209 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/PowerPC/README.txt | 18 ------------------ test/CodeGen/PowerPC/lbz-from-ld-shift.ll | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 18 deletions(-) create mode 100644 test/CodeGen/PowerPC/lbz-from-ld-shift.ll diff --git a/lib/Target/PowerPC/README.txt b/lib/Target/PowerPC/README.txt index f705139e680..9565ae131f8 100644 --- a/lib/Target/PowerPC/README.txt +++ b/lib/Target/PowerPC/README.txt @@ -255,24 +255,6 @@ int f(signed char *a, _Bool b, _Bool c) { ===-------------------------------------------------------------------------=== -This: -int test(unsigned *P) { return *P >> 24; } - -Should compile to: - -_test: - lbz r3,0(r3) - blr - -not: - -_test: - lwz r2, 0(r3) - srwi r3, r2, 24 - blr - -===-------------------------------------------------------------------------=== - On the G5, logical CR operations are more expensive in their three address form: ops that read/write the same register are half as expensive as those that read from two registers that are different from their destination. diff --git a/test/CodeGen/PowerPC/lbz-from-ld-shift.ll b/test/CodeGen/PowerPC/lbz-from-ld-shift.ll new file mode 100644 index 00000000000..3eacd6a45fb --- /dev/null +++ b/test/CodeGen/PowerPC/lbz-from-ld-shift.ll @@ -0,0 +1,18 @@ +; RUN: llc -mcpu=ppc64 < %s | FileCheck %s +target datalayout = "E-m:e-i64:64-n32:64" +target triple = "powerpc64-unknown-linux-gnu" + +; Function Attrs: nounwind readonly +define signext i32 @test(i32* nocapture readonly %P) #0 { +entry: + %0 = load i32* %P, align 4 + %shr = lshr i32 %0, 24 + ret i32 %shr + +; CHECK-LABEL: @test +; CHECK: lbz 3, 0(3) +; CHECK: blr +} + +attributes #0 = { nounwind readonly } +