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

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 2 11:39:23 PDT 2022


efriedma added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstructionCombining.cpp:4134
+            // was found for it, assume that side effect is actually absent and
+            // the instruction can be removed.
+            isa<ConstrainedFPIntrinsic>(I)) {
----------------
kpn wrote:
> efriedma wrote:
> > It's not clear to me this is the only reason a constrained FP intrinsic can be returned.  And even if it were, it's a fragile invariant.
> > 
> > Would it make sense to just have isInstructionTriviallyDead() do the right thing here? We already do something similar with isMathLibCallNoop().
> With "strict" exception behavior we are not allowed to eliminate any run-time traps. I still do not know how isInstructionTriviallyDead() can trivially know that an instruction will never trap and thus can know that removing the instruction is trivially safe.
It can prove it exactly the same way this patch is trying to do: by constant-folding the operation.


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