[PATCH] D93974: [ValueTracking] Safe assumption context for args

Gil Rapaport via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 12 13:41:35 PST 2021


gilr added a comment.

In D93974#2493723 <https://reviews.llvm.org/D93974#2493723>, @jdoerfert wrote:

> In D93974#2493646 <https://reviews.llvm.org/D93974#2493646>, @gilr wrote:
>
>> Yes, if `isaAssumeIntrinsic` stands for "is an assume or an ephemeral of an assume".
>
> Why is anything but an `llvm.assume` a problem? (Sorry I have so many questions)

No problem, a chance to verify my understanding:
So a function such as

  int f(int num) {
      __builtin_assume((num & 3) == 0);
      return num +1;
  }

ompiles under `-O3 -g0 -S -emit-llvm` into:

  define dso_local i32 @_Z1fi(i32 %0) local_unnamed_addr #0 {
    %2 = and i32 %0, 3
    %3 = icmp eq i32 %2, 0
    tail call void @llvm.assume(i1 %3)
    %4 = or i32 %0, 1
    ret i32 %4
  }

Computing the known bits of `%0` with `%2` as the context would have `isValidAssumeForContext()` return false on the assume since `%2` is one of its ephemeral values. Otherwise, simplifying `%2` by computing `%0`'s known bits would be logical bootstrapping - `%0`'s assumed zero bits would be used to simplify `%2` to zero, then `%3` to true and the assume would be lost.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93974



More information about the llvm-commits mailing list