<div dir="ltr">The load/store form is in fact in SSA. As you can see, each value is only assigned once.<div>Memory is never in a strict SSA form in just about any compiler, because it requires knowing, statically, what a load/store may actually affect.  That is statically undecidable.</div><div><br></div><div>mem2reg is taking some of the memory operations where it can figure out that they are safe to not be in memory,  and converting them to non-memory operations.</div><div>In doing so, it is taking what was previously memory operations in ssa, and converting them to register-like operations in ssa.</div><div><br></div><div>Both are still SSA.  One just looks more like the SSA you seem to expect.</div><div><br></div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr">On Tue, Dec 5, 2017 at 8:41 PM gurbani dimpal via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><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                                       ; 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                                       ; 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                                      ; 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="m_8064557085762516201gmail_signature"><div dir="ltr"><div>Thanks and Regards,<br></div>Dimpal Gurabani<br></div></div>
</div>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>