xref: /aosp_15_r20/external/llvm/test/Transforms/SimplifyCFG/2003-08-17-BranchFoldOrdering.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; This test checks to make sure that 'br X, Dest, Dest' is folded into
2*9880d681SAndroid Build Coastguard Worker; 'br Dest'.  This can only happen after the 'Z' block is eliminated.  This is
3*9880d681SAndroid Build Coastguard Worker; due to the fact that the SimplifyCFG function does not use
4*9880d681SAndroid Build Coastguard Worker; the ConstantFoldTerminator function.
5*9880d681SAndroid Build Coastguard Worker
6*9880d681SAndroid Build Coastguard Worker; RUN: opt < %s -simplifycfg -S | FileCheck %s
7*9880d681SAndroid Build Coastguard Worker
8*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: br i1 %c2
9*9880d681SAndroid Build Coastguard Worker
10*9880d681SAndroid Build Coastguard Workerdeclare void @noop()
11*9880d681SAndroid Build Coastguard Worker
12*9880d681SAndroid Build Coastguard Workerdefine i32 @test(i1 %c1, i1 %c2) {
13*9880d681SAndroid Build Coastguard Worker	call void @noop( )
14*9880d681SAndroid Build Coastguard Worker	br i1 %c1, label %A, label %Y
15*9880d681SAndroid Build Coastguard WorkerA:		; preds = %0
16*9880d681SAndroid Build Coastguard Worker	call void @noop( )
17*9880d681SAndroid Build Coastguard Worker	br i1 %c2, label %Z, label %X
18*9880d681SAndroid Build Coastguard WorkerZ:		; preds = %A
19*9880d681SAndroid Build Coastguard Worker	br label %X
20*9880d681SAndroid Build Coastguard WorkerX:		; preds = %Y, %Z, %A
21*9880d681SAndroid Build Coastguard Worker	call void @noop( )
22*9880d681SAndroid Build Coastguard Worker	ret i32 0
23*9880d681SAndroid Build Coastguard WorkerY:		; preds = %0
24*9880d681SAndroid Build Coastguard Worker	call void @noop( )
25*9880d681SAndroid Build Coastguard Worker	br label %X
26*9880d681SAndroid Build Coastguard Worker}
27*9880d681SAndroid Build Coastguard Worker
28