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

Jonas Paulsson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 19 05:14:58 PST 2020


jonpa added a comment.

In D90231#2361639 <https://reviews.llvm.org/D90231#2361639>, @joerg wrote:

> "It compiles with GCC" is not really helpful as argument because the observed behavior depends on a lot of internals. It is quite frankly impossible to be 100% identical to GCC's behavior. What LLVM guarantees is:
> (1) Folding to false happens as late as reasonable possible. It happens most importantly after the first round of function and loop optimizations.
> (2) Folding to true happens as part of constant folding etc as early as the condition is evaluated.
> (3) The result is propagated to derived expression and those are folded recursively, including dead code elimination. This happens even for -O0.
>
> That's why `__builtin_constant_p(i)` followed by the range check is fine as far as LLVM is concerned. With -O0, it fails as it doesn't have the help of SROA and the whole code branch is killed. Otherwise, `i` is a known constant and the range check is constant folded. The assembler constraint is verified using the same machinery anyway.

OK - I have tried a different approach at https://reviews.llvm.org/D91786...


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

https://reviews.llvm.org/D90231



More information about the llvm-commits mailing list