summaryrefslogtreecommitdiffstats
path: root/llvm/test/CodeGen/PowerPC
diff options
context:
space:
mode:
authorHiroshi Inoue <inouehrs@jp.ibm.com>2017-12-20 05:18:19 +0000
committerHiroshi Inoue <inouehrs@jp.ibm.com>2017-12-20 05:18:19 +0000
commit11e571e0c68f872052f8827b4ee976a54a200052 (patch)
treea29af9117ad5cdeedfc75ebc6caa1a3e8a26d21b /llvm/test/CodeGen/PowerPC
parentab2ac2906609650e9fd7bfd6ff2d3a643d93c1f1 (diff)
downloadbcm5719-llvm-11e571e0c68f872052f8827b4ee976a54a200052.tar.gz
bcm5719-llvm-11e571e0c68f872052f8827b4ee976a54a200052.zip
[PowerPC] fix a bug in redundant compare elimination
This patch fixes a bug in the redundant compare elimination reported in https://reviews.llvm.org/rL320786 and re-enables the optimization. The redundant compare elimination assumes that we can replace signed comparison with unsigned comparison for the equality check. But due to the difference in the sign extension behavior we cannot change the opcode if the comparison is against an immediate and the most significant bit of the immediate is one. Differential Revision: https://reviews.llvm.org/D41385 llvm-svn: 321147
Diffstat (limited to 'llvm/test/CodeGen/PowerPC')
-rw-r--r--llvm/test/CodeGen/PowerPC/cmp_elimination.ll32
1 files changed, 31 insertions, 1 deletions
diff --git a/llvm/test/CodeGen/PowerPC/cmp_elimination.ll b/llvm/test/CodeGen/PowerPC/cmp_elimination.ll
index 3251ae2881b..6bc8b8a041c 100644
--- a/llvm/test/CodeGen/PowerPC/cmp_elimination.ll
+++ b/llvm/test/CodeGen/PowerPC/cmp_elimination.ll
@@ -1,4 +1,3 @@
-; XFAIL: *
; RUN: llc -verify-machineinstrs < %s -mtriple=powerpc64-unknown-linux-gnu | FileCheck %s
; RUN: llc -verify-machineinstrs < %s -mtriple=powerpc64le-unknown-linux-gnu | FileCheck %s
@@ -748,6 +747,37 @@ do.end:
ret void
}
+define void @func29(i32 signext %a) {
+; We cannot merge two compares due to difference in sign extension behaviors.
+; equivalent C code example:
+; int a = .. ;
+; if (a == -1) dummy1();
+; if (a == (uint16_t)-1) dummy2();
+
+; CHECK-LABEL: @func29
+; CHECK: cmp
+; CHECK: cmp
+; CHECK: blr
+entry:
+ %cmp = icmp eq i32 %a, -1
+ br i1 %cmp, label %if.then, label %if.else
+
+if.then:
+ tail call void @dummy1()
+ br label %if.end3
+
+if.else:
+ %cmp1 = icmp eq i32 %a, 65535
+ br i1 %cmp1, label %if.then2, label %if.end3
+
+if.then2:
+ tail call void @dummy2()
+ br label %if.end3
+
+if.end3:
+ ret void
+}
+
declare void @dummy1()
declare void @dummy2()
declare void @dummy3()
OpenPOWER on IntegriCloud