[PATCH] D90231: [GVN] Don't replace argument to @llvm.is.constant.*()

Jonas Paulsson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 28 02:53:14 PDT 2020


jonpa added a comment.

In D90231#2358512 <https://reviews.llvm.org/D90231#2358512>, @lebedev.ri wrote:

> In D90231#2358503 <https://reviews.llvm.org/D90231#2358503>, @jonpa wrote:
>
>>> I'm sorry, i do not understand. Is the test case over-reduced?
>>> In land.rhs BB, %shl *is* constant, and therefore the folding happens:
>>
>> IIUC, the idea of the intrinsic is to check if a value is *compile-time* constant. %shl is known to be 0 in %land.rhs given the icmp, but during runtime it actually can have any value.
>
> In `land.rhs` it can only ever be `0`, because in `land.rhs`, `%shl` got replaced with `0`.
>
> I think i'd like to see the bigger/less reduced test case..

Sure, this is the one I was working with:

  int a, b;
  void c() {
    b = a << 12;
    if (__builtin_constant_p(b > -129 && b < 128 && __builtin_constant_p(b)) ?
          (b > -129 && b < 128 && __builtin_constant_p(b)) :
          ({ (b > -129 && b < 128 && __builtin_constant_p(b)) ? 1 : 0; }))
      asm("" : : "i"(b));
  }

clang -O2 -c

  error: invalid operand for inline asm constraint 'i'
      asm("" : : "i"(b));


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

https://reviews.llvm.org/D90231



More information about the llvm-commits mailing list