<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Nov 16, 2015 at 8:01 AM, Mehdi AMINI via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">joker.eph added inline comments.<br>
<br>
================<br>
Comment at: test/Transforms/GlobalOpt/globalsra.ll:31<br>
@@ +30,3 @@<br>
<span class="">+define void @onlystore2() {<br>
+        store i32 123, i32* getelementptr ({ i32, float, { double } }, { i32, float, { double } }* @G2, i32 0, i32 0)<br>
+        ret void<br>
</span>----------------<br>
It is strange that we can store to a constant?<br>
<span class=""><br></span></blockquote><div><br></div><div><br></div><div>It's strange in the sense that it probably doesn't do anything sensible, and is likely not well defined behavior ;-)</div><div><br></div><div>But you can't really disallow it in the IR, because if you didn't, you'd have to do things like make sure optimizations never propagated constants to certain uses.</div><div><br></div><div>IE you couldn't write:<br><br></div><div>Discover X is constant</div><div>for each use of X</div><div>  replace use with constant</div><div><br></div><div>you'd have to write</div><div><br></div><div>Discover X is constant</div><div>for each use of X</div><div>   if user of use is not a store</div><div>     replace use with constant</div><div><br></div><div>This is more expensive, and doesn't make the behavior more well defined. It's still storing to the same place (or else you wouldn't have been able to prove it constant!)</div><div><br></div><div><br></div></div></div></div>