llvm-project/llvm/test/Transforms/SimplifyCFG/switch-simplify-crash2.ll
Mingjie Xu fac9472593
[IR] Reland Optimize PHINode::removeIncomingValue() and PHINode::removeIncomingValueIf() to use the swapping strategy. (#174274)
Reland #171963, #172639 and #173444, they are reverted in
86b9f90b9574b3a7d15d28a91f6316459dcfa046 because of introducing
non-determinism in compiles.
The non-determinism has been fixed in
9b8addffa70cee5b2acc5454712d9cf78ce45710.
2026-01-04 09:24:53 +08:00

31 lines
808 B
LLVM

; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -S -passes="simplifycfg<forward-switch-cond;no-keep-loops>" < %s | FileCheck %s
define i8 @test() {
; CHECK-LABEL: @test(
; CHECK-NEXT: entry:
; CHECK-NEXT: br label [[LOOP2:%.*]]
; CHECK: loop2:
; CHECK-NEXT: [[PHI2:%.*]] = phi i8 [ [[SPEC_SELECT:%.*]], [[LOOP2]] ], [ 0, [[ENTRY:%.*]] ]
; CHECK-NEXT: [[COND:%.*]] = icmp eq i8 [[PHI2]], 0
; CHECK-NEXT: [[SPEC_SELECT]] = select i1 [[COND]], i8 0, i8 [[PHI2]]
; CHECK-NEXT: br label [[LOOP2]]
;
entry:
br label %loop
loop:
%phi1 = phi i8 [ 0, %entry ], [ %phi2, %loop2 ]
br label %loop2
loop2:
%phi2 = phi i8 [ %phi1, %loop ], [ 0, %loop2 ]
switch i8 %phi2, label %loop [
i8 0, label %loop2
i8 1, label %exit
]
exit:
ret i8 0
}