summaryrefslogtreecommitdiffstats
path: root/llvm/test/CodeGen
diff options
context:
space:
mode:
authorEhsan Amiri <amehsan@ca.ibm.com>2016-11-18 10:41:44 +0000
committerEhsan Amiri <amehsan@ca.ibm.com>2016-11-18 10:41:44 +0000
commit85818684c6ccb136ccf5a1dfdca6968fe7d1037b (patch)
treed34d450ba915b8a6239fab40e40f2da77c604854 /llvm/test/CodeGen
parentc00c9a9f61e44dbb75e5b023de038f6096ab9329 (diff)
downloadbcm5719-llvm-85818684c6ccb136ccf5a1dfdca6968fe7d1037b.tar.gz
bcm5719-llvm-85818684c6ccb136ccf5a1dfdca6968fe7d1037b.zip
[PPC][DAGCombine] Convert SETCC to subtract when the result is zero extended
When we see a SETCC whose only users are zero extend operations, we can replace it with a subtraction. This results in doing all calculations in GPRs and avoids CR use. Currently we do this only for ULT, ULE, UGT and UGE condition codes. There are ways that this can be extended. For example for signed condition codes. In that case we will be introducing additional sign extend instructions, so more careful profitability analysis may be required. Another direction to extend this is for equal, not equal conditions. Also when users of SETCC are any_ext or sign_ext, we might be able to do something similar. llvm-svn: 287329
Diffstat (limited to 'llvm/test/CodeGen')
-rw-r--r--llvm/test/CodeGen/PowerPC/setcc-to-sub.ll96
1 files changed, 96 insertions, 0 deletions
diff --git a/llvm/test/CodeGen/PowerPC/setcc-to-sub.ll b/llvm/test/CodeGen/PowerPC/setcc-to-sub.ll
new file mode 100644
index 00000000000..335bb403cd7
--- /dev/null
+++ b/llvm/test/CodeGen/PowerPC/setcc-to-sub.ll
@@ -0,0 +1,96 @@
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
+; RUN: -mcpu=pwr8 < %s | FileCheck %s
+
+%class.PB2 = type { [1 x i32], %class.PB1* }
+%class.PB1 = type { [1 x i32], i64, i64, i32 }
+
+; Function Attrs: norecurse nounwind readonly
+define zeroext i1 @test1(%class.PB2* %s_a, %class.PB2* %s_b) local_unnamed_addr #0 {
+entry:
+ %arrayidx.i6 = bitcast %class.PB2* %s_a to i32*
+ %0 = load i32, i32* %arrayidx.i6, align 8, !tbaa !1
+ %and.i = and i32 %0, 8
+ %arrayidx.i37 = bitcast %class.PB2* %s_b to i32*
+ %1 = load i32, i32* %arrayidx.i37, align 8, !tbaa !1
+ %and.i4 = and i32 %1, 8
+ %cmp.i5 = icmp ult i32 %and.i, %and.i4
+ ret i1 %cmp.i5
+
+; CHECK-LABEL: @test1
+; CHECK: rlwinm [[REG1:[0-9]*]]
+; CHECK-NEXT: rlwinm [[REG2:[0-9]*]]
+; CHECK-NEXT: sub [[REG3:[0-9]*]], [[REG1]], [[REG2]]
+; CHECK-NEXT: rldicl 3, [[REG3]]
+; CHECK: blr
+
+}
+
+; Function Attrs: norecurse nounwind readonly
+define zeroext i1 @test2(%class.PB2* %s_a, %class.PB2* %s_b) local_unnamed_addr #0 {
+entry:
+ %arrayidx.i6 = bitcast %class.PB2* %s_a to i32*
+ %0 = load i32, i32* %arrayidx.i6, align 8, !tbaa !1
+ %and.i = and i32 %0, 8
+ %arrayidx.i37 = bitcast %class.PB2* %s_b to i32*
+ %1 = load i32, i32* %arrayidx.i37, align 8, !tbaa !1
+ %and.i4 = and i32 %1, 8
+ %cmp.i5 = icmp ule i32 %and.i, %and.i4
+ ret i1 %cmp.i5
+
+; CHECK-LABEL: @test2
+; CHECK: rlwinm [[REG1:[0-9]*]]
+; CHECK-NEXT: rlwinm [[REG2:[0-9]*]]
+; CHECK-NEXT: sub [[REG3:[0-9]*]], [[REG2]], [[REG1]]
+; CHECK-NEXT: rldicl [[REG4:[0-9]*]], [[REG3]]
+; CHECK-NEXT: xori 3, [[REG4]], 1
+; CHECK: blr
+
+}
+
+; Function Attrs: norecurse nounwind readonly
+define zeroext i1 @test3(%class.PB2* %s_a, %class.PB2* %s_b) local_unnamed_addr #0 {
+entry:
+ %arrayidx.i6 = bitcast %class.PB2* %s_a to i32*
+ %0 = load i32, i32* %arrayidx.i6, align 8, !tbaa !1
+ %and.i = and i32 %0, 8
+ %arrayidx.i37 = bitcast %class.PB2* %s_b to i32*
+ %1 = load i32, i32* %arrayidx.i37, align 8, !tbaa !1
+ %and.i4 = and i32 %1, 8
+ %cmp.i5 = icmp ugt i32 %and.i, %and.i4
+ ret i1 %cmp.i5
+
+; CHECK-LABEL: @test3
+; CHECK: rlwinm [[REG1:[0-9]*]]
+; CHECK-NEXT: rlwinm [[REG2:[0-9]*]]
+; CHECK-NEXT: sub [[REG3:[0-9]*]], [[REG2]], [[REG1]]
+; CHECK-NEXT: rldicl 3, [[REG3]]
+; CHECK: blr
+
+}
+
+; Function Attrs: norecurse nounwind readonly
+define zeroext i1 @test4(%class.PB2* %s_a, %class.PB2* %s_b) local_unnamed_addr #0 {
+entry:
+ %arrayidx.i6 = bitcast %class.PB2* %s_a to i32*
+ %0 = load i32, i32* %arrayidx.i6, align 8, !tbaa !1
+ %and.i = and i32 %0, 8
+ %arrayidx.i37 = bitcast %class.PB2* %s_b to i32*
+ %1 = load i32, i32* %arrayidx.i37, align 8, !tbaa !1
+ %and.i4 = and i32 %1, 8
+ %cmp.i5 = icmp uge i32 %and.i, %and.i4
+ ret i1 %cmp.i5
+
+; CHECK-LABEL: @test4
+; CHECK: rlwinm [[REG1:[0-9]*]]
+; CHECK-NEXT: rlwinm [[REG2:[0-9]*]]
+; CHECK-NEXT: sub [[REG3:[0-9]*]], [[REG1]], [[REG2]]
+; CHECK-NEXT: rldicl [[REG4:[0-9]*]], [[REG3]]
+; CHECK-NEXT: xori 3, [[REG4]], 1
+; CHECK: blr
+
+}
+
+!1 = !{!2, !2, i64 0}
+!2 = !{!"int", !3, i64 0}
+!3 = !{!"omnipotent char", !4, i64 0}
+!4 = !{!"Simple C++ TBAA"}
OpenPOWER on IntegriCloud