[PATCH] D114766: If constrained intrinsic is replaced, remove its side effect

Serge Pavlov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 2 19:27:46 PST 2021


sepavloff added a comment.

In D114766#3165135 <https://reviews.llvm.org/D114766#3165135>, @nikic wrote:

> I think constrained FP intrinsics are basically in the same situation as math libcalls with errno. These get constant folded, and removal is handled via isMathLibCallNoop() in wouldInstructionBeTriviallyDead(). I would expected constrained FP intrinsics to basically work the same way. Of course, the implementation can be shared with the actual folding code, so for example wouldInstructionBeTriviallyDead() could check whether all intrinsic args are constant, if they are call the constrained FP folding function internally, and then say that it is trivially dead if it folds. (Or something more nuanced -- presumably there are cases where it's possible to determine the result but not drop, or maybe drop but not fold. Not familiar with the details here.)
>
> Changing the infrastructure so that InstSimplify/ConstantFolding could report that the instruction is in fact dead (and not just the result known) is certainly also a possibility, but it's likely not the path of least resistance.

Removal of constrained intrinsic calls is not limited by constant folding. InstSimplify can make replacement of calls with non-const arguments, like the transformation 'x * 0 -> 0' in fast-math mode. Other similar transformations would be added in future. Recognition if all these cases in `wouldInstructionBeTriviallyDead` would make it too large.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114766



More information about the llvm-commits mailing list