<div dir="ltr">Hello Marcello,<div><br></div><div>We're currently planning to disable this optimization - at least temporarily - for cases where we'll end up creating PHIs of pointers for performance reasons (see PR30188).</div><div><br></div><div>Having said that - I don't believe this is something you can rely on for correctness.</div><div>From an IR semantics perspective, this is a completely legal transformation that can be introduced by any optimization pass, for whatever reason. We can't control that throughout the entire optimization stack with a TTI hook. Two potential solutions I can see are to either (a) teach your backend to handle it (by disambiguating these loads in a pre-ISel IR pass), or (b) use some kind of type-system trick to make it impossible (say, assign a different address space to each distinct pointer in the front end).<br></div><div><br></div><div>Thanks,</div><div>  Michael</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Sep 2, 2016 at 11:39 AM, Marcello Maggioni via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@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">Hello,<br>
<br>
I’m getting some failures on our internal testing happening after this commit.<br>
<br>
I dug a little bit into it and it ended up begin caused by the fact that this optimization is sinking some instructions that shouldn’t be sunk<br>
<br>
In particular we have some loads that need to have a constant address to be selected, because they load from a “special address space”.<br>
<br>
What the optimization is doing is extracting the “getelementptr” , making an instruction out of it, sinking the load and using a PHI to select between the address.<br>
This breaks our selection of this types of loads.<br>
<br>
We need a way to tell this code to not do that.<br>
<br>
The solutions I kind of see for this is:<br>
<br>
- Add some TTI hook that stops this sinking from happening for instructions that don’t support that like in this case (maybe added in canSinkInstructions())<br>
<br>
- Add some TTI hook that is a little bit coarser that stops the optimization to run altogether. In particular this thing is creating “unstructured control-flow” in some cases and this is not always good (and actually generally bad) on GPU targets.<br>
<br>
- Put the optimization in another separate pass. It seems to be doing stuff that is a little bit more than just “Simplifying the CFG” actually. It is actually making it more complex by splitting blocks around. I wonder if it would make sense for it to live it in a separate pass that can be enabled or disabled at the compiler pipeline level so that one that wants to opt out can just avoid to add the pass to the pipeline.<br>
<br>
Open for suggestions on what the best solution for this is.<br>
<br>
Thanks,<br>
Marcello<br>
______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org">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/<wbr>mailman/listinfo/llvm-dev</a><br>
</blockquote></div><br></div>