[llvm] r290903 - [InstCombine] tighten checks for tests of assume -> metadata transform; NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 3 11:32:12 PST 2017


Author: spatel
Date: Tue Jan  3 13:32:11 2017
New Revision: 290903

URL: http://llvm.org/viewvc/llvm-project?rev=290903&view=rev
Log:
[InstCombine] tighten checks for tests of assume -> metadata transform; NFC

Modified:
    llvm/trunk/test/Transforms/InstCombine/assume.ll

Modified: llvm/trunk/test/Transforms/InstCombine/assume.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/assume.ll?rev=290903&r1=290902&r2=290903&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/assume.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/assume.ll Tue Jan  3 13:32:11 2017
@@ -188,41 +188,56 @@ entry:
 
 declare void @escape(i32* %a)
 
-; Do we canonicalize a nonnull assumption on a load into
-; metadata form?
+; Canonicalize a nonnull assumption on a load into metadata form.
+
 define i1 @nonnull1(i32** %a) {
-entry:
+; CHECK-LABEL: @nonnull1(
+; CHECK-NEXT:    [[LOAD:%.*]] = load i32*, i32** %a, align 8, !nonnull !0
+; CHECK-NEXT:    tail call void @escape(i32* nonnull [[LOAD]])
+; CHECK-NEXT:    ret i1 false
+;
   %load = load i32*, i32** %a
   %cmp = icmp ne i32* %load, null
   tail call void @llvm.assume(i1 %cmp)
   tail call void @escape(i32* %load)
   %rval = icmp eq i32* %load, null
   ret i1 %rval
-
-; CHECK-LABEL: @nonnull1
-; CHECK: !nonnull
-; CHECK-NOT: call void @llvm.assume
-; CHECK: ret i1 false
 }
 
 ; Make sure the above canonicalization applies only
 ; to pointer types.  Doing otherwise would be illegal.
+
 define i1 @nonnull2(i32* %a) {
-entry:
+; CHECK-LABEL: @nonnull2(
+; CHECK-NEXT:    [[LOAD:%.*]] = load i32, i32* %a, align 4
+; CHECK-NEXT:    [[CMP:%.*]] = icmp ne i32 [[LOAD]], 0
+; CHECK-NEXT:    tail call void @llvm.assume(i1 [[CMP]])
+; CHECK-NEXT:    [[RVAL:%.*]] = icmp eq i32 [[LOAD]], 0
+; CHECK-NEXT:    ret i1 [[RVAL]]
+;
   %load = load i32, i32* %a
   %cmp = icmp ne i32 %load, 0
   tail call void @llvm.assume(i1 %cmp)
   %rval = icmp eq i32 %load, 0
   ret i1 %rval
-
-; CHECK-LABEL: @nonnull2
-; CHECK-NOT: !nonnull
-; CHECK: call void @llvm.assume
 }
 
 ; Make sure the above canonicalization does not trigger
 ; if the assume is control dependent on something else
+
 define i1 @nonnull3(i32** %a, i1 %control) {
+; CHECK-LABEL: @nonnull3(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    [[LOAD:%.*]] = load i32*, i32** %a, align 8
+; CHECK-NEXT:    br i1 %control, label %taken, label %not_taken
+; CHECK:       taken:
+; CHECK-NEXT:    [[CMP:%.*]] = icmp ne i32* [[LOAD]], null
+; CHECK-NEXT:    tail call void @llvm.assume(i1 [[CMP]])
+; CHECK-NEXT:    [[RVAL:%.*]] = icmp eq i32* [[LOAD]], null
+; CHECK-NEXT:    ret i1 [[RVAL]]
+; CHECK:       not_taken:
+; CHECK-NEXT:    ret i1 true
+;
 entry:
   %load = load i32*, i32** %a
   %cmp = icmp ne i32* %load, null
@@ -233,17 +248,21 @@ taken:
   ret i1 %rval
 not_taken:
   ret i1 true
-
-; CHECK-LABEL: @nonnull3
-; CHECK-NOT: !nonnull
-; CHECK: call void @llvm.assume
 }
 
 ; Make sure the above canonicalization does not trigger
-; if the path from the load to the assume is potentially 
+; if the path from the load to the assume is potentially
 ; interrupted by an exception being thrown
+
 define i1 @nonnull4(i32** %a) {
-entry:
+; CHECK-LABEL: @nonnull4(
+; CHECK-NEXT:    [[LOAD:%.*]] = load i32*, i32** %a, align 8
+; CHECK-NEXT:    tail call void @escape(i32* [[LOAD]])
+; CHECK-NEXT:    [[CMP:%.*]] = icmp ne i32* [[LOAD]], null
+; CHECK-NEXT:    tail call void @llvm.assume(i1 [[CMP]])
+; CHECK-NEXT:    [[RVAL:%.*]] = icmp eq i32* [[LOAD]], null
+; CHECK-NEXT:    ret i1 [[RVAL]]
+;
   %load = load i32*, i32** %a
   ;; This call may throw!
   tail call void @escape(i32* %load)
@@ -251,15 +270,9 @@ entry:
   tail call void @llvm.assume(i1 %cmp)
   %rval = icmp eq i32* %load, null
   ret i1 %rval
-
-; CHECK-LABEL: @nonnull4
-; CHECK-NOT: !nonnull
-; CHECK: call void @llvm.assume
 }
 
 
-
-
 attributes #0 = { nounwind uwtable }
 attributes #1 = { nounwind }
 




More information about the llvm-commits mailing list