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

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 28 02:38:42 PDT 2020


lebedev.ri added a comment.

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..

> I see your point that this could actually be seen as a compile-time constant, but still the purpose here is to let the programmer use this as a predicate in a small function to generate different code depending on the invocation. In my example, the inline asm constraint "i" is to be used whenever the value is a constant (and legal for "i").  What happened was that a non-constant value (%shl) was used with is.constant(), which then (in a slightly more complicated test case) ended up as the value used with "i" in a block where it was true during runtime.
>
> That is however illegal code and expected to be removed by this predicate - it is not OK to have an inline asm with "i" and a loaded value in a block just because an icmp proved it to be 0...   :-)




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

https://reviews.llvm.org/D90231



More information about the llvm-commits mailing list