<div dir="ltr">Hi,<div><br></div><div>Ah, yes, the AssumptionTracker is feature light. You can use the PostDomTree to find the assumption that unconditionally apply to the current instruction.</div><div>To generalize that we would need a solver (still waiting for Polyhedral Value Analysis by the way...) and accumulate the "divergence" on the post dominance frontier.</div><div>Do we have such thing?<br><div><br></div><div>Anyway, after looking into the use of the @llvm.expect intrinsic, I found out that we do propagate-up in some situation.</div></div><div>For example we "detect" which side of a phi is probably taken by looking at "expect" downstream of the phi and find if it would be incompatible with all the other branches.</div><div>We only propagate up through "copies" or "xor".</div><div><br></div><div>Anyway, I agree a "void @llvm.expect_true(i1 %cond)" is more aligned with the @llvm.assume (but I am unsure if this is a good or a bad thing).</div><div><br></div><div>Semantically speaking, I see @llvm.expect_true as being a function that is instantaneous in average, but excruciatingly slow when its condition is false (thus making any other optimization irrelevant for the slow case).</div><div>As opposed to @llvm.assume which is instantaneous if true, but destroys the universe and all that exists when the condition is false.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Mar 28, 2018 at 12:22 PM, Michael Kruse <span dir="ltr"><<a href="mailto:llvmdev@meinersbur.de" target="_blank">llvmdev@meinersbur.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
As far as I understand, AssumptionTracker is just a compile-time<br>
optimization to avoid having to iterate over instructions to find a<br>
relevant @llvm.assume. In case of @llvm.expect, one can just look up<br>
the definition, which would be the @llvm.expect. Some time ago there<br>
was a patch that replaced AssumptionTracker but got reverted.<br>
<br>
I see an issue with @llvm.expect's design. It should not be part of<br>
the SSA which defines semantics instead of optional optimization<br>
hints. With<br>
<span class="">%b = i64 call @llvm.expect(i64 %a, i64 16)<br>
</span>in the code, %a can still be used, has the same value, but has not the<br>
same hint associated with it.<br>
<br>
To specify a range, I could imagine a @llvm.expect.range intrinsic. Or<br>
alternatively, and more general,<br>
void @llvm.expect_true(i1 %cond)<br>
that is also tracked by AssumptionTracker, but with the difference<br>
that when %cond evaluates to false, it is still defined behaviour.<br>
<span class="HOEnZb"><font color="#888888"><br>
Michael<br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><b>Alexandre Isoard</b><br></div></div>
</div>