<div dir="ltr"><div><div><div><div>I read in LLVM language
reference manual that LLVM IR is in SSA Form, but when i compiled it
using clang, it is giving me the below form which i can't see in SSA form and even i found that there is a
pass -mem2reg to convert it into SSA form. Then, i am unable to
understand that why it's written in manual that it is in SSA form. I
feel if it is in SSA then we should not need to convert it. Could you please
clarify my doubt, i am stuck here. </div><br></div><div>.c Program:</div><div><br></div><div>int main() {<br> int a=0, b=1, p=2, q=3, x, y, m, n, g;<br> if (m > n) {<br> x = a;<br> y = b;<br> }<br> else {<br> x = p;<br> y = q;<br> }<br> g = x + y;<br> return 0;<br>}<br><br></div>.ll Program:<br></div><br>define i32 @main() #0 {<br> %1 = alloca i32, align 4<br> %a = alloca i32, align 4<br> %b = alloca i32, align 4<br> %p = alloca i32, align 4<br> %q = alloca i32, align 4<br> %x = alloca i32, align 4<br> %y = alloca i32, align 4<br> %m = alloca i32, align 4<br> %n = alloca i32, align 4<br> %g = alloca i32, align 4<br> store i32 0, i32* %1, align 4<br> store i32 0, i32* %a, align 4<br> store i32 1, i32* %b, align 4<br> store i32 2, i32* %p, align 4<br> store i32 3, i32* %q, align 4<br> %2 = load i32, i32* %m, align 4<br> %3 = load i32, i32* %n, align 4<br> %4 = icmp sgt i32 %2, %3<br> br i1 %4, label %5, label %8<br><br>; <label>:5 <wbr> ; preds = %0<br> %6 = load i32, i32* %a, align 4<br> store i32 %6, i32* %x, align 4<br> %7 = load i32, i32* %b, align 4<br> store i32 %7, i32* %y, align 4<br> br label %11<br><br>; <label>:8 <wbr> ; preds = %0<br> %9 = load i32, i32* %p, align 4<br> store i32 %9, i32* %x, align 4<br> %10 = load i32, i32* %q, align 4<br> store i32 %10, i32* %y, align 4<br> br label %11<br><br>; <label>:11 <wbr> ; preds = %8, %5<br> %12 = load i32, i32* %x, align 4<br> %13 = load i32, i32* %y, align 4<br> %14 = add nsw i32 %12, %13<br> store i32 %14, i32* %g, align 4<br> ret i32 0<br>}<br></div><br>-- <br><div class="gmail_signature"><div dir="ltr"><div>Thanks and Regards,<br></div>Dimpal Gurabani<br></div></div>
</div>