[llvm-dev] Evaluate SCEV on "typically expected value"

Michael Kruse via llvm-dev llvm-dev at lists.llvm.org
Wed Mar 28 12:22:35 PDT 2018


Hi,

As far as I understand, AssumptionTracker is just a compile-time
optimization to avoid having to iterate over instructions to find a
relevant @llvm.assume. In case of @llvm.expect, one can just look up
the definition, which would be the @llvm.expect. Some time ago there
was a patch that replaced AssumptionTracker but got reverted.

I see an issue with @llvm.expect's design. It should not be part of
the SSA which defines semantics instead of optional optimization
hints. With
%b = i64 call @llvm.expect(i64 %a, i64 16)
in the code, %a can still be used, has the same value, but has not the
same hint associated with it.

To specify a range, I could imagine a @llvm.expect.range intrinsic. Or
alternatively, and more general,
void @llvm.expect_true(i1 %cond)
that is also tracked by AssumptionTracker, but with the difference
that when %cond evaluates to false, it is still defined behaviour.

Michael


More information about the llvm-dev mailing list