summaryrefslogtreecommitdiffstats
path: root/llvm/test
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2012-03-10 17:56:03 +0000
committerBill Wendling <isanbard@gmail.com>2012-03-10 17:56:03 +0000
commit0624d2a1ecc2c0e3b17076cde1ed9781700d8c72 (patch)
treeb422b0c2a2fd9fb33ef88695b6f13b85a4e36b1c /llvm/test
parentb52221e941474cdb9fe25808e1936601342ba6fc (diff)
downloadbcm5719-llvm-0624d2a1ecc2c0e3b17076cde1ed9781700d8c72.tar.gz
bcm5719-llvm-0624d2a1ecc2c0e3b17076cde1ed9781700d8c72.zip
Make this transformation slightly less agressive and more correct.
The 'CmpInst::isFalseWhenEqual' function returns 'false' for values other than simply equality. For instance, it returns 'false' for <= or >=. This isn't the correct behavior for this transformation, which is checking for strict equality and non-equality. It was causing the gcc.c-torture/execute/frame-address.c test to fail because it would completely (and incorrectly) optimize a whole function into a 'ret i32 0'. llvm-svn: 152497
Diffstat (limited to 'llvm/test')
-rw-r--r--llvm/test/Transforms/InstCombine/2012-03-10-InstCombine.ll35
1 files changed, 35 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/2012-03-10-InstCombine.ll b/llvm/test/Transforms/InstCombine/2012-03-10-InstCombine.ll
new file mode 100644
index 00000000000..68989972549
--- /dev/null
+++ b/llvm/test/Transforms/InstCombine/2012-03-10-InstCombine.ll
@@ -0,0 +1,35 @@
+; RUN: opt < %s -instcombine | FileCheck %s
+
+; Derived from gcc.c-torture/execute/frame-address.c
+
+; CHECK: @func
+; CHECK: return:
+; CHECK-NOT: ret i32 0
+; CHECK: ret i32 %retval
+
+define i32 @func(i8* %c, i8* %f) nounwind uwtable readnone noinline ssp {
+entry:
+ %d = alloca i8, align 1
+ store i8 0, i8* %d, align 1
+ %cmp = icmp ugt i8* %d, %c
+ br i1 %cmp, label %if.else, label %if.then
+
+if.then: ; preds = %entry
+ %cmp2 = icmp ule i8* %d, %f
+ %not.cmp1 = icmp uge i8* %c, %f
+ %.cmp2 = and i1 %cmp2, %not.cmp1
+ %land.ext = zext i1 %.cmp2 to i32
+ br label %return
+
+if.else: ; preds = %entry
+ %cmp5 = icmp uge i8* %d, %f
+ %not.cmp3 = icmp ule i8* %c, %f
+ %.cmp5 = and i1 %cmp5, %not.cmp3
+ %land.ext7 = zext i1 %.cmp5 to i32
+ br label %return
+
+return: ; preds = %if.else, %if.then
+ %retval.0 = phi i32 [ %land.ext, %if.then ], [ %land.ext7, %if.else ]
+ ret i32 %retval.0
+}
+
OpenPOWER on IntegriCloud