[llvm] r260544 - Add a test case to show isKnownNonZero() returns correctly; NFC

Jun Bum Lim via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 11 09:11:49 PST 2016


Author: junbuml
Date: Thu Feb 11 11:11:49 2016
New Revision: 260544

URL: http://llvm.org/viewvc/llvm-project?rev=260544&view=rev
Log:
Add a test case to show isKnownNonZero() returns correctly; NFC

Summary:
Added a test case just to make sure that isKnownNonZero() returns false
when we cannot guarantee that a ConstantExpr is a non-zero constant.

Reviewers: sanjoy, majnemer, mcrosier, nlewycky

Subscribers: nlewycky, mssimpso, mcrosier, llvm-commits

Differential Revision: http://reviews.llvm.org/D16908

Modified:
    llvm/trunk/test/Transforms/InstSimplify/compare.ll

Modified: llvm/trunk/test/Transforms/InstSimplify/compare.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstSimplify/compare.ll?rev=260544&r1=260543&r2=260544&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstSimplify/compare.ll (original)
+++ llvm/trunk/test/Transforms/InstSimplify/compare.ll Thu Feb 11 11:11:49 2016
@@ -333,6 +333,21 @@ define i1 @or(i32 %x) {
 ; CHECK: ret i1 false
 }
 
+; Do not simplify if we cannot guarantee that the ConstantExpr is a non-zero
+; constant.
+ at GV = common global i32* null
+define i1 @or_constexp(i32 %x) {
+; CHECK-LABEL: @or_constexp(
+entry:
+  %0 = and i32 ptrtoint (i32** @GV to i32), 32
+  %o = or i32 %x, %0
+  %c = icmp eq i32 %o, 0
+  ret i1 %c
+; CHECK: or
+; CHECK-NEXT: icmp eq
+; CHECK-NOT: ret i1 false
+}
+
 define i1 @shl1(i32 %x) {
 ; CHECK-LABEL: @shl1(
   %s = shl i32 1, %x




More information about the llvm-commits mailing list