[PATCH] D118426: [InstCombine] Remove side effect of replaced constrained intrinsics

Serge Pavlov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 23 10:37:57 PST 2022


sepavloff added a comment.

In D118426#3338322 <https://reviews.llvm.org/D118426#3338322>, @kpn wrote:

> In D118426#3337963 <https://reviews.llvm.org/D118426#3337963>, @sepavloff wrote:
>
>> In D118426#3337489 <https://reviews.llvm.org/D118426#3337489>, @kpn wrote:
>>
>>> It seems like these dangling, useless instructions would interfere with subsequent optimizations until finally they might or might not get removed here. And constant folding isn't sufficient to duplicate the logic of the transform pass that determined the instruction could be deleted.
>>
>> InstCombine is called several times, it calls constant folding and instruction simplification functions. It looks like a good place to get rid of such useless instructions.
>
> My point is that it shouldn't be needed for eliminating dead constrained intrinsics that are still around only because the exception behavior is "strict" when a transform pass has proved to itself that no exception can ever take place.

Absolutely. It requires that transformations that may remove intrinsic calls be aware about constrained intrinsics. Removing unneeded instruction in separate pass still might make sense in some cases, similar to separate DCE passes.

> We do run InstCombiner often enough that it is a decent place to eliminate useless instructions. I don't think it is ideal, but it's fine.

It is not ideal, but InstCombiner would be a transformation pass that would know about constrained intrinsics. It calls `SimplifyCall` (and consequently calls `ConstantFoldCall`), so it already has all necessary information to make removal of constfolded intrinsics, no need to reevaluate them. At least removal of unneeded intrinsic call here wouldn't cost much.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118426



More information about the llvm-commits mailing list