[PowerPC] Add a test for truncating a shifted load
authorHal Finkel <hfinkel@anl.gov>
Mon, 5 Jan 2015 21:33:14 +0000 (21:33 +0000)
committerHal Finkel <hfinkel@anl.gov>
Mon, 5 Jan 2015 21:33:14 +0000 (21:33 +0000)
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
test/CodeGen/PowerPC/lbz-from-ld-shift.ll [new file with mode: 0644]

index f705139e68099d919df8282d728bad7ee33ad88d..9565ae131f88b03370ceccc21ee01babc234f513 100644 (file)
@@ -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 (file)
index 0000000..3eacd6a
--- /dev/null
@@ -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 }
+