[PATCH] D118387: [IPSCCP] Switch away from Instruction::isSafeToRemove()

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 21 03:38:45 PDT 2022


fhahn added inline comments.


================
Comment at: llvm/lib/Transforms/Scalar/SCCP.cpp:98
+
+  return (!isa<CallInst>(I) || !I->mayHaveSideEffects()) &&
+         !I->isTerminator() && !I->isEHPad();
----------------
Why is this extra code needed?

It looks like `wouldInstructionBeTriviallyDead` doesn't consider atomic loads from globals as trivially dead, which is causing an issue with IPSCCP as it requires such loads to be removed.

According to https://llvm.org/docs/Atomics.html#atomics-and-ir-optimization, atomic loads from globals can be constant folded, so I *think* `wouldInstructionBeTriviallyDead` should consider them as trivially dead.


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

https://reviews.llvm.org/D118387



More information about the llvm-commits mailing list