xref: /aosp_15_r20/external/llvm/test/CodeGen/Generic/undef-phi.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -verify-machineinstrs -verify-coalescing
2*9880d681SAndroid Build Coastguard Worker;
3*9880d681SAndroid Build Coastguard Worker; This function has a PHI with one undefined input. Verify that PHIElimination
4*9880d681SAndroid Build Coastguard Worker; inserts an IMPLICIT_DEF instruction in the predecessor so all paths to the use
5*9880d681SAndroid Build Coastguard Worker; pass through a def.
6*9880d681SAndroid Build Coastguard Worker
7*9880d681SAndroid Build Coastguard Worker%struct.xx_stack = type { i32, %struct.xx_stack* }
8*9880d681SAndroid Build Coastguard Worker
9*9880d681SAndroid Build Coastguard Workerdefine i32 @push(%struct.xx_stack* %stack) nounwind uwtable readonly ssp {
10*9880d681SAndroid Build Coastguard Workerentry:
11*9880d681SAndroid Build Coastguard Worker  %tobool1 = icmp eq %struct.xx_stack* %stack, null
12*9880d681SAndroid Build Coastguard Worker  br i1 %tobool1, label %for.end, label %for.body
13*9880d681SAndroid Build Coastguard Worker
14*9880d681SAndroid Build Coastguard Workerfor.body:
15*9880d681SAndroid Build Coastguard Worker  %stack.addr.02 = phi %struct.xx_stack* [ %0, %for.body ], [ %stack, %entry ]
16*9880d681SAndroid Build Coastguard Worker  %next = getelementptr inbounds %struct.xx_stack, %struct.xx_stack* %stack.addr.02, i64 0, i32 1
17*9880d681SAndroid Build Coastguard Worker  %0 = load %struct.xx_stack*, %struct.xx_stack** %next, align 8
18*9880d681SAndroid Build Coastguard Worker  %tobool = icmp eq %struct.xx_stack* %0, null
19*9880d681SAndroid Build Coastguard Worker  br i1 %tobool, label %for.end, label %for.body
20*9880d681SAndroid Build Coastguard Worker
21*9880d681SAndroid Build Coastguard Workerfor.end:
22*9880d681SAndroid Build Coastguard Worker  %top.0.lcssa = phi %struct.xx_stack* [ undef, %entry ], [ %stack.addr.02, %for.body ]
23*9880d681SAndroid Build Coastguard Worker  %first = getelementptr inbounds %struct.xx_stack, %struct.xx_stack* %top.0.lcssa, i64 0, i32 0
24*9880d681SAndroid Build Coastguard Worker  %1 = load i32, i32* %first, align 4
25*9880d681SAndroid Build Coastguard Worker  ret i32 %1
26*9880d681SAndroid Build Coastguard Worker}
27