[InstCombine] Remove side effect of replaced constrained intrinsics
authorSerge Pavlov <sepavloff@gmail.com>
Thu, 5 May 2022 05:02:42 +0000 (12:02 +0700)
committerSerge Pavlov <sepavloff@gmail.com>
Sat, 7 May 2022 12:04:11 +0000 (19:04 +0700)
commiteb28da89a6594a017e067a2a4043c2f2bb2c425e
tree5bbb08d988ed6223fc58d64cc2055b2e4e88b2a5
parente571e1a6c356ef045a69220cb8a96e6e26a72209
[InstCombine] Remove side effect of replaced constrained intrinsics

If a constrained intrinsic call was replaced by some value, it was not
removed in some cases. The dangling instruction resulted in useless
instructions executed in runtime. It happened because constrained
intrinsics usually have side effect, it is used to model the interaction
with floating-point environment. In some cases side effect is actually
absent or can be ignored.

This change adds specific treatment of constrained intrinsics so that
their side effect can be removed if it actually absents.

Differential Revision: https://reviews.llvm.org/D118426
llvm/include/llvm/Analysis/InstructionSimplify.h
llvm/lib/Analysis/InstructionSimplify.cpp
llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
llvm/test/Transforms/InstCombine/constrained.ll [new file with mode: 0644]