[PATCH] D75799: [JumpThreading] Don't create PHI nodes with "is.constant" values

Joerg Sonnenberger via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 18 18:28:39 PDT 2020


joerg added a comment.

I was discussing this with Bill off-list to get a better idea of the original test case. Basically, with the new constant intrinsic pass, we can provide a stronger semantic: the default LLVM pass chain always constant folds expressions involving is.constant and performs DCE trivially dead branches resulting from the former folding. This means that if the original expression is adjusted from:

  if (__builtin_expect(!!(sz >= 0 && sz < bytes), 0)) {
      if (!__builtin_constant_p(bytes))
      ...
  }

to the functionally equivalent:

  if (!(__builtin_constant_p(sz) && __builtin_constant_p(bytes) && sz >= 0 && sz >= bytes) && __builtin_expect(!!(sz >= 0 && sz < bytes), 0)) {
      if (!__builtin_constant_p(bytes))
      ...
  }

then we can actually ensure proper DCE even with -O0 in the default pass chain. That depends over all on two properties:

- If __builtin_constant_p is constant folded by clang, it must DCE the appropiate places.
- the constant intrinsic pass is run

With -O1 or higher, this should work in general.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75799





More information about the llvm-commits mailing list