[PATCH] D112016: [IR] Introduce load assume operand bundle

Johannes Doerfert via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 18 11:39:56 PDT 2021


jdoerfert added a comment.

In D112016#3071082 <https://reviews.llvm.org/D112016#3071082>, @aeubanks wrote:

> In D112016#3071078 <https://reviews.llvm.org/D112016#3071078>, @jdoerfert wrote:
>
>>> This is useful for exposing the vtable value of a C++ object after its constructor without having to insert a load into the instruction stream.
>>
>> Why is an assume better than a load?
>
> Adding an extra load will affect cost modelling, e.g. inliner thresholds, and other various ad-hoc cost heuristics. assumes are free.

I really want to get to the outlined assumes function model but I guess this is an OK first step.

- outlined model ---

  call @llvm.assume(i1 true) ["assume_fn"(void (i32*, i32) @__assume_equal, i32* %P, i32 %V]
  
  define void @__assume_equal(i32* %P, i32 %V) {
    %L = load i32* %P
    %cmp = icmp eq i32 %L, %V
    call @llvm.assume(i1 %cmp)
  }

because it is way more flexible. We can use it to encode
`__builtin_assume(foobar() == barfoo());`
without risking side-effects to leak or cause regressions,
as another example.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112016/new/

https://reviews.llvm.org/D112016



More information about the llvm-commits mailing list