[LICM][SCCP] Regenerate test checks (NFC)

This commit is contained in:
Nikita Popov 2021-07-22 21:06:39 +02:00
parent f719dff043
commit 4294657bd5
5 changed files with 746 additions and 408 deletions

View File

@ -1,3 +1,4 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -licm -S | FileCheck %s ; RUN: opt < %s -licm -S | FileCheck %s
; RUN: opt -aa-pipeline=basic-aa -passes='require<aa>,require<targetir>,require<scalar-evolution>,require<opt-remark-emit>,loop(licm)' < %s -S | FileCheck %s ; RUN: opt -aa-pipeline=basic-aa -passes='require<aa>,require<targetir>,require<scalar-evolution>,require<opt-remark-emit>,loop(licm)' < %s -S | FileCheck %s
@ -5,6 +6,27 @@ target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
target triple = "i386-pc-windows-msvc18.0.0" target triple = "i386-pc-windows-msvc18.0.0"
define void @test1(i32* %s, i1 %b) personality i32 (...)* @__CxxFrameHandler3 { define void @test1(i32* %s, i1 %b) personality i32 (...)* @__CxxFrameHandler3 {
; CHECK-LABEL: @test1(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[TMP0:%.*]] = call i32 @pure_computation()
; CHECK-NEXT: br label [[WHILE_COND:%.*]]
; CHECK: while.cond:
; CHECK-NEXT: br i1 [[B:%.*]], label [[TRY_CONT_LOOPEXIT:%.*]], label [[WHILE_BODY:%.*]]
; CHECK: while.body:
; CHECK-NEXT: invoke void @may_throw()
; CHECK-NEXT: to label [[WHILE_COND]] unwind label [[CATCH_DISPATCH:%.*]]
; CHECK: catch.dispatch:
; CHECK-NEXT: [[DOTLCSSA1:%.*]] = phi i32 [ [[TMP0]], [[WHILE_BODY]] ]
; CHECK-NEXT: [[CS:%.*]] = catchswitch within none [label %catch] unwind to caller
; CHECK: catch:
; CHECK-NEXT: [[CP:%.*]] = catchpad within [[CS]] [i8* null, i32 64, i8* null]
; CHECK-NEXT: store i32 [[DOTLCSSA1]], i32* [[S:%.*]], align 4
; CHECK-NEXT: catchret from [[CP]] to label [[TRY_CONT:%.*]]
; CHECK: try.cont.loopexit:
; CHECK-NEXT: br label [[TRY_CONT]]
; CHECK: try.cont:
; CHECK-NEXT: ret void
;
entry: entry:
br label %while.cond br label %while.cond
@ -14,7 +36,7 @@ while.cond: ; preds = %while.body, %entry
while.body: ; preds = %while.cond while.body: ; preds = %while.cond
invoke void @may_throw() invoke void @may_throw()
to label %while.cond unwind label %catch.dispatch to label %while.cond unwind label %catch.dispatch
catch.dispatch: ; preds = %while.body catch.dispatch: ; preds = %while.body
%.lcssa1 = phi i32 [ %0, %while.body ] %.lcssa1 = phi i32 [ %0, %while.body ]
@ -29,11 +51,23 @@ try.cont: ; preds = %catch, %while.cond
ret void ret void
} }
; CHECK-LABEL: define void @test1(
; CHECK: %[[CALL:.*]] = call i32 @pure_computation()
; CHECK: phi i32 [ %[[CALL]]
define void @test2(i32* %s, i1 %b) personality i32 (...)* @__CxxFrameHandler3 { define void @test2(i32* %s, i1 %b) personality i32 (...)* @__CxxFrameHandler3 {
; CHECK-LABEL: @test2(
; CHECK-NEXT: entry:
; CHECK-NEXT: br label [[WHILE_COND:%.*]]
; CHECK: while.cond:
; CHECK-NEXT: br i1 [[B:%.*]], label [[TRY_CONT:%.*]], label [[WHILE_BODY:%.*]]
; CHECK: while.body:
; CHECK-NEXT: invoke void @may_throw()
; CHECK-NEXT: to label [[WHILE_COND]] unwind label [[CATCH_DISPATCH:%.*]]
; CHECK: catch.dispatch:
; CHECK-NEXT: [[CP:%.*]] = cleanuppad within none []
; CHECK-NEXT: [[TMP0:%.*]] = call i32 @pure_computation() [ "funclet"(token [[CP]]) ]
; CHECK-NEXT: store i32 [[TMP0]], i32* [[S:%.*]], align 4
; CHECK-NEXT: cleanupret from [[CP]] unwind to caller
; CHECK: try.cont:
; CHECK-NEXT: ret void
;
entry: entry:
br label %while.cond br label %while.cond
@ -43,7 +77,7 @@ while.cond: ; preds = %while.body, %entry
while.body: ; preds = %while.cond while.body: ; preds = %while.cond
invoke void @may_throw() invoke void @may_throw()
to label %while.cond unwind label %catch.dispatch to label %while.cond unwind label %catch.dispatch
catch.dispatch: ; preds = %while.body catch.dispatch: ; preds = %while.body
%.lcssa1 = phi i32 [ %0, %while.body ] %.lcssa1 = phi i32 [ %0, %while.body ]
@ -55,13 +89,38 @@ try.cont: ; preds = %catch, %while.cond
ret void ret void
} }
; CHECK-LABEL: define void @test2(
; CHECK: %[[CP:.*]] = cleanuppad within none []
; CHECK-NEXT: %[[CALL:.*]] = call i32 @pure_computation() [ "funclet"(token %[[CP]]) ]
; CHECK-NEXT: store i32 %[[CALL]], i32* %s
; CHECK-NEXT: cleanupret from %[[CP]] unwind to caller
define void @test3(i1 %a, i1 %b, i1 %c) personality i32 (...)* @__CxxFrameHandler3 { define void @test3(i1 %a, i1 %b, i1 %c) personality i32 (...)* @__CxxFrameHandler3 {
; CHECK-LABEL: @test3(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[DOTFRAME:%.*]] = alloca i8, align 4
; CHECK-NEXT: [[DOTFRAME2:%.*]] = alloca i8, align 4
; CHECK-NEXT: [[BC:%.*]] = bitcast i8* [[DOTFRAME]] to i32*
; CHECK-NEXT: [[BC2:%.*]] = bitcast i8* [[DOTFRAME2]] to i32*
; CHECK-NEXT: br i1 [[A:%.*]], label [[TRY_SUCCESS_OR_CAUGHT:%.*]], label [[FORBODY_PREHEADER:%.*]]
; CHECK: forbody.preheader:
; CHECK-NEXT: store i32 1, i32* [[BC]], align 4
; CHECK-NEXT: store i32 2, i32* [[BC2]], align 4
; CHECK-NEXT: br label [[FORBODY:%.*]]
; CHECK: catch.object.Throwable:
; CHECK-NEXT: [[CP:%.*]] = catchpad within [[CS:%.*]] [i8* null, i32 64, i8* null]
; CHECK-NEXT: unreachable
; CHECK: try.success.or.caught.loopexit:
; CHECK-NEXT: br label [[TRY_SUCCESS_OR_CAUGHT]]
; CHECK: try.success.or.caught:
; CHECK-NEXT: ret void
; CHECK: postinvoke:
; CHECK-NEXT: br i1 [[B:%.*]], label [[ELSE:%.*]], label [[FORCOND_BACKEDGE:%.*]]
; CHECK: forcond.backedge:
; CHECK-NEXT: br i1 [[C:%.*]], label [[TRY_SUCCESS_OR_CAUGHT_LOOPEXIT:%.*]], label [[FORBODY]]
; CHECK: catch.dispatch:
; CHECK-NEXT: [[CS]] = catchswitch within none [label %catch.object.Throwable] unwind to caller
; CHECK: forbody:
; CHECK-NEXT: invoke void @may_throw()
; CHECK-NEXT: to label [[POSTINVOKE:%.*]] unwind label [[CATCH_DISPATCH:%.*]]
; CHECK: else:
; CHECK-NEXT: invoke void @may_throw()
; CHECK-NEXT: to label [[FORCOND_BACKEDGE]] unwind label [[CATCH_DISPATCH]]
;
entry: entry:
%.frame = alloca i8, align 4 %.frame = alloca i8, align 4
%.frame2 = alloca i8, align 4 %.frame2 = alloca i8, align 4
@ -89,20 +148,13 @@ forbody: ; preds = %forcond.backedge, %
store i32 1, i32* %bc, align 4 store i32 1, i32* %bc, align 4
store i32 2, i32* %bc2, align 4 store i32 2, i32* %bc2, align 4
invoke void @may_throw() invoke void @may_throw()
to label %postinvoke unwind label %catch.dispatch to label %postinvoke unwind label %catch.dispatch
else: ; preds = %postinvoke else: ; preds = %postinvoke
invoke void @may_throw() invoke void @may_throw()
to label %forcond.backedge unwind label %catch.dispatch to label %forcond.backedge unwind label %catch.dispatch
} }
; CHECK-LABEL: define void @test3(
; CHECK-LABEL: forbody.preheader:
; CHECK: store i32 1, i32* %bc, align 4
; CHECK: store i32 2, i32* %bc2, align 4
; CHECK: catchswitch within none
; CHECK-LABEL: forbody:
declare void @may_throw() declare void @may_throw()
declare i32 @pure_computation() nounwind argmemonly readonly declare i32 @pure_computation() nounwind argmemonly readonly

File diff suppressed because it is too large Load Diff

View File

@ -1,31 +1,35 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -sccp -loop-deletion -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S | FileCheck %s ; RUN: opt < %s -sccp -loop-deletion -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S | FileCheck %s
declare double @sqrt(double) readnone nounwind declare double @sqrt(double) readnone nounwind
%empty = type {} %empty = type {}
declare %empty @has_side_effects() declare %empty @has_side_effects()
define double @test_0(i32 %param) {
; CHECK-LABEL: @test_0(
; CHECK-NOT: br
entry:
; No matter how hard you try, sqrt(1.0) is always 1.0. This allows the ; No matter how hard you try, sqrt(1.0) is always 1.0. This allows the
; optimizer to delete this loop. ; optimizer to delete this loop.
define double @test_0(i32 %param) {
br label %Loop ; CHECK-LABEL: @test_0(
; CHECK-NEXT: entry:
; CHECK-NEXT: ret double 1.000000e+00
;
entry:
br label %Loop
Loop: ; preds = %Loop, %entry Loop: ; preds = %Loop, %entry
%I2 = phi i32 [ 0, %entry ], [ %I3, %Loop ] ; <i32> [#uses=1] %I2 = phi i32 [ 0, %entry ], [ %I3, %Loop ]
%V = phi double [ 1.000000e+00, %entry ], [ %V2, %Loop ] ; <double> [#uses=2] %V = phi double [ 1.000000e+00, %entry ], [ %V2, %Loop ]
%V2 = call double @sqrt( double %V ) ; <double> [#uses=1] %V2 = call double @sqrt( double %V )
%I3 = add i32 %I2, 1 ; <i32> [#uses=2] %I3 = add i32 %I2, 1
%tmp.7 = icmp ne i32 %I3, %param ; <i1> [#uses=1] %tmp.7 = icmp ne i32 %I3, %param
br i1 %tmp.7, label %Loop, label %Exit br i1 %tmp.7, label %Loop, label %Exit
Exit: ; preds = %Loop Exit: ; preds = %Loop
ret double %V ret double %V
} }
define i32 @test_1() { define i32 @test_1() {
; CHECK-LABEL: @test_1( ; CHECK-LABEL: @test_1(
; CHECK: call %empty @has_side_effects() ; CHECK-NEXT: [[TMP1:%.*]] = call [[EMPTY:%.*]] @has_side_effects()
; CHECK-NEXT: ret i32 0
;
%1 = call %empty @has_side_effects() %1 = call %empty @has_side_effects()
ret i32 0 ret i32 0
} }

View File

@ -1,3 +1,4 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature
; RUN: opt < %s -ipsccp -S | FileCheck %s ; RUN: opt < %s -ipsccp -S | FileCheck %s
; PR36485 ; PR36485
; musttail call result can\'t be replaced with a constant, unless the call ; musttail call result can\'t be replaced with a constant, unless the call
@ -6,11 +7,25 @@
declare i32 @external() declare i32 @external()
define i8* @start(i8 %v) { define i8* @start(i8 %v) {
; CHECK-LABEL: define {{[^@]+}}@start
; CHECK-SAME: (i8 [[V:%.*]]) {
; CHECK-NEXT: [[C1:%.*]] = icmp eq i8 [[V]], 0
; CHECK-NEXT: br i1 [[C1]], label [[TRUE:%.*]], label [[FALSE:%.*]]
; CHECK: true:
; CHECK-NEXT: [[CA:%.*]] = musttail call i8* @side_effects(i8 0)
; CHECK-NEXT: ret i8* [[CA]]
; CHECK: false:
; CHECK-NEXT: [[C2:%.*]] = icmp eq i8 [[V]], 1
; CHECK-NEXT: br i1 [[C2]], label [[C2_TRUE:%.*]], label [[C2_FALSE:%.*]]
; CHECK: c2_true:
; CHECK-NEXT: ret i8* null
; CHECK: c2_false:
; CHECK-NEXT: [[CA2:%.*]] = musttail call i8* @dont_zap_me(i8 [[V]])
; CHECK-NEXT: ret i8* [[CA2]]
;
%c1 = icmp eq i8 %v, 0 %c1 = icmp eq i8 %v, 0
br i1 %c1, label %true, label %false br i1 %c1, label %true, label %false
true: true:
; CHECK: %ca = musttail call i8* @side_effects(i8 0)
; CHECK: ret i8* %ca
%ca = musttail call i8* @side_effects(i8 %v) %ca = musttail call i8* @side_effects(i8 %v)
ret i8* %ca ret i8* %ca
false: false:
@ -18,41 +33,48 @@ false:
br i1 %c2, label %c2_true, label %c2_false br i1 %c2, label %c2_true, label %c2_false
c2_true: c2_true:
%ca1 = musttail call i8* @no_side_effects(i8 %v) %ca1 = musttail call i8* @no_side_effects(i8 %v)
; CHECK: ret i8* null
ret i8* %ca1 ret i8* %ca1
c2_false: c2_false:
; CHECK: %ca2 = musttail call i8* @dont_zap_me(i8 %v)
; CHECK: ret i8* %ca2
%ca2 = musttail call i8* @dont_zap_me(i8 %v) %ca2 = musttail call i8* @dont_zap_me(i8 %v)
ret i8* %ca2 ret i8* %ca2
} }
define internal i8* @side_effects(i8 %v) { define internal i8* @side_effects(i8 %v) {
; CHECK-LABEL: define {{[^@]+}}@side_effects
; CHECK-SAME: (i8 [[V:%.*]]) {
; CHECK-NEXT: [[I1:%.*]] = call i32 @external()
; CHECK-NEXT: [[CA:%.*]] = musttail call i8* @start(i8 0)
; CHECK-NEXT: ret i8* [[CA]]
;
%i1 = call i32 @external() %i1 = call i32 @external()
; since this goes back to `start` the SCPP should be see that the return value ; since this goes back to `start` the SCPP should be see that the return value
; is always `null`. ; is always `null`.
; The call can't be removed due to `external` call above, though. ; The call can't be removed due to `external` call above, though.
; CHECK: %ca = musttail call i8* @start(i8 0)
%ca = musttail call i8* @start(i8 %v) %ca = musttail call i8* @start(i8 %v)
; Thus the result must be returned anyway ; Thus the result must be returned anyway
; CHECK: ret i8* %ca
ret i8* %ca ret i8* %ca
} }
; The call to this function is removed, so the return value must be zapped
define internal i8* @no_side_effects(i8 %v) readonly nounwind { define internal i8* @no_side_effects(i8 %v) readonly nounwind {
; The call to this function is removed, so the return value must be zapped ; CHECK-LABEL: define {{[^@]+}}@no_side_effects
; CHECK: ret i8* undef ; CHECK-SAME: (i8 [[V:%.*]]) #[[ATTR0:[0-9]+]] {
; CHECK-NEXT: ret i8* undef
;
ret i8* null ret i8* null
} }
; The call to this function cannot be removed due to side effects. Thus the
; return value should stay as it is, and should not be zapped.
define internal i8* @dont_zap_me(i8 %v) { define internal i8* @dont_zap_me(i8 %v) {
; CHECK-LABEL: define {{[^@]+}}@dont_zap_me
; CHECK-SAME: (i8 [[V:%.*]]) {
; CHECK-NEXT: [[I1:%.*]] = call i32 @external()
; CHECK-NEXT: ret i8* null
;
%i1 = call i32 @external() %i1 = call i32 @external()
; The call to this function cannot be removed due to side effects. Thus the
; return value should stay as it is, and should not be zapped.
; CHECK: ret i8* null
ret i8* null ret i8* null
} }

View File

@ -1,25 +1,31 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -S -ipsccp | FileCheck %s ; RUN: opt < %s -S -ipsccp | FileCheck %s
; PR5596 ; PR5596
; IPSCCP should propagate the 0 argument, eliminate the switch, and propagate ; IPSCCP should propagate the 0 argument, eliminate the switch, and propagate
; the result. ; the result.
; CHECK: define i32 @main() #0 {
; CHECK-NEXT: entry:
; CHECK-NOT: call
; CHECK-NEXT: ret i32 123
define i32 @main() noreturn nounwind { define i32 @main() noreturn nounwind {
; CHECK-LABEL: @main(
; CHECK-NEXT: entry:
; CHECK-NEXT: ret i32 123
;
entry: entry:
%call2 = tail call i32 @wwrite(i64 0) nounwind %call2 = tail call i32 @wwrite(i64 0) nounwind
ret i32 %call2 ret i32 %call2
} }
define internal i32 @wwrite(i64 %i) nounwind readnone { define internal i32 @wwrite(i64 %i) nounwind readnone {
; CHECK-LABEL: @wwrite(
; CHECK-NEXT: entry:
; CHECK-NEXT: br label [[SW_DEFAULT:%.*]]
; CHECK: sw.default:
; CHECK-NEXT: ret i32 undef
;
entry: entry:
switch i64 %i, label %sw.default [ switch i64 %i, label %sw.default [
i64 3, label %return i64 3, label %return
i64 10, label %return i64 10, label %return
] ]
sw.default: sw.default: