[PATCH] D38856: [IPSCCP] Remove calls without side effects

Chris Bieneman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 12 17:39:32 PDT 2017


beanz added inline comments.


================
Comment at: lib/Transforms/Scalar/SCCP.cpp:1929
         if (tryToReplaceWithConstant(Solver, Inst)) {
-          if (!isa<CallInst>(Inst) && !isa<TerminatorInst>(Inst))
+          if ((!isa<CallInst>(Inst) || !Inst->mayHaveSideEffects()) &&
+              !isa<TerminatorInst>(Inst))
----------------
sanjoy wrote:
> Can we just make this `!Inst->mayHaveSideEffects() && !isa<TerminatorInst>(Inst)`?  Otherwise we're assuming that non-calls that aren't terminators are not side effecting, which may be correct specifically for the instructions that `tryToReplaceWithConstant` returns true for, but isn't true in general.
The problem with that is that we do have instructions with side effects that we want to fold away. For example we have `test/Transforms/SCCP/atomic-load-store.ll` which tests that we do erase atomic loads and stores.


https://reviews.llvm.org/D38856





More information about the llvm-commits mailing list