minimal C code that would generate IR code using phi

Hi,

I am trying to understand phi better. I know what it means.

https://en.wikipedia.org/wiki/Static_single_assignment_form

But when I tried to create a minimal code using if-else with
unbalanced statements to change a variable in C, it still did not
generate IR code using phi.

Does anybody have a minimal C code that would generate IR code using
phi? Thanks.

Clang never really generates phis itself because it's easier to
generate code that simply uses a stack variable (you don't have to
keep track of control flow). The Mem2Reg pass in LLVM is what converts
Clang's output into a form with phis.

If you run Clang at an optimization above -O0 (e.g. "clang -O1 -Xclang
-disable-llvm-passes -emit-llvm ...") then run "opt -mem2reg" manually
you'll closest to what Clang would have emitted if it did do phis.

Cheers.

Tim.

I don't know if this is minimal, but it's short:

--- p.c ---
int bar(int a);

int foo(int a) {
   return a > 0 ? bar(a-1) : -bar(0);
}