[llvm] r347882 - [SimplifyCFG] auto-generate complete checks; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 29 08:28:37 PST 2018
Author: spatel
Date: Thu Nov 29 08:28:37 2018
New Revision: 347882
URL: http://llvm.org/viewvc/llvm-project?rev=347882&view=rev
Log:
[SimplifyCFG] auto-generate complete checks; NFC
Modified:
llvm/trunk/test/Transforms/SimplifyCFG/implied-and-or.ll
Modified: llvm/trunk/test/Transforms/SimplifyCFG/implied-and-or.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SimplifyCFG/implied-and-or.ll?rev=347882&r1=347881&r2=347882&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/SimplifyCFG/implied-and-or.ll (original)
+++ llvm/trunk/test/Transforms/SimplifyCFG/implied-and-or.ll Thu Nov 29 08:28:37 2018
@@ -1,16 +1,23 @@
-; RUN: opt %s -S -simplifycfg | FileCheck %s
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -S -simplifycfg | FileCheck %s
declare void @foo()
declare void @bar()
-
-; CHECK-LABEL: @test_and1
-; CHECK: taken:
-; CHECK-NOT: cmp3
-; CHECK: call void @bar()
-; CHECK-NEXT: call void @foo()
-; CHECK: ret
define void @test_and1(i32 %a, i32 %b) {
+; CHECK-LABEL: @test_and1(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i32 [[A:%.*]], 0
+; CHECK-NEXT: [[CMP2:%.*]] = icmp eq i32 [[B:%.*]], 0
+; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]]
+; CHECK-NEXT: br i1 [[AND]], label [[TAKEN:%.*]], label [[END:%.*]]
+; CHECK: taken:
+; CHECK-NEXT: call void @bar()
+; CHECK-NEXT: call void @foo()
+; CHECK-NEXT: br label [[END]]
+; CHECK: end:
+; CHECK-NEXT: ret void
+;
entry:
%cmp1 = icmp eq i32 %a, 0
%cmp2 = icmp eq i32 %b, 0
@@ -31,15 +38,24 @@ end:
}
; We can't infer anything if the result of the 'and' is false
-; CHECK-LABEL: @test_and2
-; CHECK: taken:
-; CHECK: call void @bar()
-; CHECK: %cmp3
-; CHECK: br i1 %cmp3
-; CHECK: if.then:
-; CHECK: call void @foo()
-; CHECK: ret
+
define void @test_and2(i32 %a, i32 %b) {
+; CHECK-LABEL: @test_and2(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i32 [[A:%.*]], 0
+; CHECK-NEXT: [[CMP2:%.*]] = icmp eq i32 [[B:%.*]], 0
+; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]]
+; CHECK-NEXT: br i1 [[AND]], label [[END:%.*]], label [[TAKEN:%.*]]
+; CHECK: taken:
+; CHECK-NEXT: call void @bar()
+; CHECK-NEXT: [[CMP3:%.*]] = icmp eq i32 [[A]], 0
+; CHECK-NEXT: br i1 [[CMP3]], label [[IF_THEN:%.*]], label [[END]]
+; CHECK: if.then:
+; CHECK-NEXT: call void @foo()
+; CHECK-NEXT: br label [[END]]
+; CHECK: end:
+; CHECK-NEXT: ret void
+;
entry:
%cmp1 = icmp eq i32 %a, 0
%cmp2 = icmp eq i32 %b, 0
@@ -59,13 +75,20 @@ end:
ret void
}
-; CHECK-LABEL: @test_or1
-; CHECK: taken:
-; CHECK-NOT: cmp3
-; CHECK: call void @bar()
-; CHECK-NEXT: call void @foo()
-; CHECK: ret
define void @test_or1(i32 %a, i32 %b) {
+; CHECK-LABEL: @test_or1(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i32 [[A:%.*]], 0
+; CHECK-NEXT: [[CMP2:%.*]] = icmp eq i32 [[B:%.*]], 0
+; CHECK-NEXT: [[OR:%.*]] = or i1 [[CMP1]], [[CMP2]]
+; CHECK-NEXT: br i1 [[OR]], label [[END:%.*]], label [[TAKEN:%.*]]
+; CHECK: taken:
+; CHECK-NEXT: call void @bar()
+; CHECK-NEXT: call void @foo()
+; CHECK-NEXT: br label [[END]]
+; CHECK: end:
+; CHECK-NEXT: ret void
+;
entry:
%cmp1 = icmp eq i32 %a, 0
%cmp2 = icmp eq i32 %b, 0
@@ -86,14 +109,24 @@ end:
}
; We can't infer anything if the result of the 'or' is true
-; CHECK-LABEL: @test_or2
-; CHECK: call void @bar()
-; CHECK: %cmp3
-; CHECK: br i1 %cmp3
-; CHECK: if.then:
-; CHECK: call void @foo()
-; CHECK: ret
+
define void @test_or2(i32 %a, i32 %b) {
+; CHECK-LABEL: @test_or2(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i32 [[A:%.*]], 0
+; CHECK-NEXT: [[CMP2:%.*]] = icmp eq i32 [[B:%.*]], 0
+; CHECK-NEXT: [[OR:%.*]] = or i1 [[CMP1]], [[CMP2]]
+; CHECK-NEXT: br i1 [[OR]], label [[TAKEN:%.*]], label [[END:%.*]]
+; CHECK: taken:
+; CHECK-NEXT: call void @bar()
+; CHECK-NEXT: [[CMP3:%.*]] = icmp eq i32 [[A]], 0
+; CHECK-NEXT: br i1 [[CMP3]], label [[IF_THEN:%.*]], label [[END]]
+; CHECK: if.then:
+; CHECK-NEXT: call void @foo()
+; CHECK-NEXT: br label [[END]]
+; CHECK: end:
+; CHECK-NEXT: ret void
+;
entry:
%cmp1 = icmp eq i32 %a, 0
%cmp2 = icmp eq i32 %b, 0
@@ -114,13 +147,23 @@ end:
}
; We can recurse a tree of 'and' or 'or's.
-; CHECK-LABEL: @test_and_recurse1
-; CHECK: taken:
-; CHECK-NEXT: call void @bar()
-; CHECK-NEXT: call void @foo()
-; CHECK-NEXT: br label %end
-; CHECK: ret
+
define void @test_and_recurse1(i32 %a, i32 %b, i32 %c) {
+; CHECK-LABEL: @test_and_recurse1(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[CMPA:%.*]] = icmp eq i32 [[A:%.*]], 0
+; CHECK-NEXT: [[CMPB:%.*]] = icmp eq i32 [[B:%.*]], 0
+; CHECK-NEXT: [[CMPC:%.*]] = icmp eq i32 [[C:%.*]], 0
+; CHECK-NEXT: [[AND1:%.*]] = and i1 [[CMPA]], [[CMPB]]
+; CHECK-NEXT: [[AND2:%.*]] = and i1 [[AND1]], [[CMPC]]
+; CHECK-NEXT: br i1 [[AND2]], label [[TAKEN:%.*]], label [[END:%.*]]
+; CHECK: taken:
+; CHECK-NEXT: call void @bar()
+; CHECK-NEXT: call void @foo()
+; CHECK-NEXT: br label [[END]]
+; CHECK: end:
+; CHECK-NEXT: ret void
+;
entry:
%cmpa = icmp eq i32 %a, 0
%cmpb = icmp eq i32 %b, 0
@@ -143,14 +186,37 @@ end:
}
; Check to make sure we don't recurse too deep.
-; CHECK-LABEL: @test_and_recurse2
-; CHECK: taken:
-; CHECK-NEXT: call void @bar()
-; CHECK-NEXT: %cmp3 = icmp eq i32 %a, 0
-; CHECK-NEXT: br i1 %cmp3, label %if.then, label %end
-; CHECK: ret
+
define void @test_and_recurse2(i32 %a, i32 %b, i32 %c, i32 %d, i32 %e, i32 %f,
- i32 %g, i32 %h) {
+; CHECK-LABEL: @test_and_recurse2(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[CMPA:%.*]] = icmp eq i32 [[A:%.*]], 0
+; CHECK-NEXT: [[CMPB:%.*]] = icmp eq i32 [[B:%.*]], 0
+; CHECK-NEXT: [[CMPC:%.*]] = icmp eq i32 [[C:%.*]], 0
+; CHECK-NEXT: [[CMPD:%.*]] = icmp eq i32 [[D:%.*]], 0
+; CHECK-NEXT: [[CMPE:%.*]] = icmp eq i32 [[E:%.*]], 0
+; CHECK-NEXT: [[CMPF:%.*]] = icmp eq i32 [[F:%.*]], 0
+; CHECK-NEXT: [[CMPG:%.*]] = icmp eq i32 [[G:%.*]], 0
+; CHECK-NEXT: [[CMPH:%.*]] = icmp eq i32 [[H:%.*]], 0
+; CHECK-NEXT: [[AND1:%.*]] = and i1 [[CMPA]], [[CMPB]]
+; CHECK-NEXT: [[AND2:%.*]] = and i1 [[AND1]], [[CMPC]]
+; CHECK-NEXT: [[AND3:%.*]] = and i1 [[AND2]], [[CMPD]]
+; CHECK-NEXT: [[AND4:%.*]] = and i1 [[AND3]], [[CMPE]]
+; CHECK-NEXT: [[AND5:%.*]] = and i1 [[AND4]], [[CMPF]]
+; CHECK-NEXT: [[AND6:%.*]] = and i1 [[AND5]], [[CMPG]]
+; CHECK-NEXT: [[AND7:%.*]] = and i1 [[AND6]], [[CMPH]]
+; CHECK-NEXT: br i1 [[AND7]], label [[TAKEN:%.*]], label [[END:%.*]]
+; CHECK: taken:
+; CHECK-NEXT: call void @bar()
+; CHECK-NEXT: [[CMP3:%.*]] = icmp eq i32 [[A]], 0
+; CHECK-NEXT: br i1 [[CMP3]], label [[IF_THEN:%.*]], label [[END]]
+; CHECK: if.then:
+; CHECK-NEXT: call void @foo()
+; CHECK-NEXT: br label [[END]]
+; CHECK: end:
+; CHECK-NEXT: ret void
+;
+ i32 %g, i32 %h) {
entry:
%cmpa = icmp eq i32 %a, 0
%cmpb = icmp eq i32 %b, 0
@@ -181,3 +247,4 @@ if.then:
end:
ret void
}
+
More information about the llvm-commits
mailing list