Changeset View
Changeset View
Standalone View
Standalone View
llvm/test/Transforms/SCCP/switch.ll
Show All 12 Lines | |||||
; CHECK-NEXT: ret void | ; CHECK-NEXT: ret void | ||||
; | ; | ||||
switch i32 undef, label %d [] | switch i32 undef, label %d [] | ||||
d: | d: | ||||
call void @foo() | call void @foo() | ||||
ret void | ret void | ||||
} | } | ||||
define i32 @test_duplicate_successors_phi(i1 %c, i32 %x) { | define i32 @test_duplicate_successors_phi(i1 %c, i32 %x) { | ||||
nikic: This test change shows another weakness of the previous approach: Even though we already… | |||||
; CHECK-LABEL: @test_duplicate_successors_phi( | ; CHECK-LABEL: @test_duplicate_successors_phi( | ||||
; CHECK-NEXT: entry: | ; CHECK-NEXT: entry: | ||||
; CHECK-NEXT: br i1 [[C:%.*]], label [[SWITCH:%.*]], label [[END:%.*]] | ; CHECK-NEXT: br i1 [[C:%.*]], label [[SWITCH:%.*]], label [[END:%.*]] | ||||
; CHECK: switch: | ; CHECK: switch: | ||||
; CHECK-NEXT: switch i32 -1, label [[SWITCH_DEFAULT:%.*]] [ | ; CHECK-NEXT: br label [[SWITCH_DEFAULT:%.*]] | ||||
; CHECK-NEXT: i32 0, label [[END]] | |||||
; CHECK-NEXT: i32 1, label [[END]] | |||||
; CHECK-NEXT: ] | |||||
; CHECK: switch.default: | ; CHECK: switch.default: | ||||
; CHECK-NEXT: ret i32 -1 | ; CHECK-NEXT: ret i32 -1 | ||||
; CHECK: end: | ; CHECK: end: | ||||
; CHECK-NEXT: [[PHI:%.*]] = phi i32 [ [[X:%.*]], [[ENTRY:%.*]] ], [ 1, [[SWITCH]] ], [ 1, [[SWITCH]] ] | ; CHECK-NEXT: ret i32 [[X:%.*]] | ||||
; CHECK-NEXT: ret i32 [[PHI]] | |||||
; | ; | ||||
entry: | entry: | ||||
br i1 %c, label %switch, label %end | br i1 %c, label %switch, label %end | ||||
switch: | switch: | ||||
switch i32 -1, label %switch.default [ | switch i32 -1, label %switch.default [ | ||||
i32 0, label %end | i32 0, label %end | ||||
i32 1, label %end | i32 1, label %end | ||||
▲ Show 20 Lines • Show All 182 Lines • Show Last 20 Lines |
This test change shows another weakness of the previous approach: Even though we already determined that here only the default edge is feasible, we did not make use of this fact, because the target block is still reachable through a different edge. Because ConstantFoldTerminator was called for the predecessors of unreachable blocks, this case was missed.