summaryrefslogtreecommitdiff
path: root/test/CodeGen/PowerPC/opt-cmp-inst-cr0-live.ll
diff options
context:
space:
mode:
authorHiroshi Inoue <inouehrs@jp.ibm.com>2017-10-26 09:01:51 +0000
committerHiroshi Inoue <inouehrs@jp.ibm.com>2017-10-26 09:01:51 +0000
commite703b246767c422aef5c917a1bbd77bddcfefc4a (patch)
tree25f820f4b1cc62eaf689a568d07b20de2bf0121b /test/CodeGen/PowerPC/opt-cmp-inst-cr0-live.ll
parentddfb984471803325e47e182966abb05d634cf30a (diff)
[PowerPC] Use record-form instruction for Less-or-Equal -1 and Greater-or-Equal 1
Currently a record-form instruction is used for comparison of "greater than -1" and "less than 1" by modifying the predicate (e.g. LT 1 into LE 0) in addition to the naive case of comparison against 0. This patch also enables emitting a record-form instruction for "less than or equal to -1" (i.e. "less than 0") and "greater than or equal to 1" (i.e. "greater than 0") to increase the optimization opportunities. Differential Revision: https://reviews.llvm.org/D38941 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316647 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGen/PowerPC/opt-cmp-inst-cr0-live.ll')
-rw-r--r--test/CodeGen/PowerPC/opt-cmp-inst-cr0-live.ll36
1 files changed, 36 insertions, 0 deletions
diff --git a/test/CodeGen/PowerPC/opt-cmp-inst-cr0-live.ll b/test/CodeGen/PowerPC/opt-cmp-inst-cr0-live.ll
index 43d4add243d..5176cdcb600 100644
--- a/test/CodeGen/PowerPC/opt-cmp-inst-cr0-live.ll
+++ b/test/CodeGen/PowerPC/opt-cmp-inst-cr0-live.ll
@@ -1,4 +1,5 @@
; RUN: llc -verify-machineinstrs -print-before=peephole-opt -print-after=peephole-opt -mtriple=powerpc64-unknown-linux-gnu -o /dev/null 2>&1 < %s | FileCheck %s
+; RUN: llc -verify-machineinstrs -print-before=peephole-opt -print-after=peephole-opt -mtriple=powerpc64le-unknown-linux-gnu -o /dev/null 2>&1 < %s | FileCheck %s
; CHECK-LABEL: fn1
define signext i32 @fn1(i32 %baz) {
@@ -99,3 +100,38 @@ foo:
bar:
ret i32 0
}
+
+; This test confirms record-form instructions are emitted for comparison
+; against a non-zero value.
+
+; CHECK-LABEL: fn6
+define i8* @fn6(i8* readonly %p) {
+; CHECK: LBZU
+; CHECK: EXTSBo
+; CHECK-NOT: CMP
+; CHECK: BCC
+; CHECK: LBZU
+; CHECK: EXTSBo
+; CHECK-NOT: CMP
+; CHECK: BCC
+
+entry:
+ %incdec.ptr = getelementptr inbounds i8, i8* %p, i64 -1
+ %0 = load i8, i8* %incdec.ptr
+ %cmp = icmp sgt i8 %0, -1
+ br i1 %cmp, label %out, label %if.end
+
+if.end:
+ %incdec.ptr2 = getelementptr inbounds i8, i8* %p, i64 -2
+ %1 = load i8, i8* %incdec.ptr2
+ %cmp4 = icmp sgt i8 %1, -1
+ br i1 %cmp4, label %out, label %cleanup
+
+out:
+ %p.addr.0 = phi i8* [ %incdec.ptr, %entry ], [ %incdec.ptr2, %if.end ]
+ br label %cleanup
+
+cleanup:
+ %retval.0 = phi i8* [ %p.addr.0, %out ], [ null, %if.end ]
+ ret i8* %retval.0
+}