[PATCH] D32664: [LoopUnswitch] Don't remove instructions with side effects after folding them

Davide Italiano via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 28 16:49:47 PDT 2017


davide added inline comments.


================
Comment at: lib/Transforms/Scalar/LoopUnswitch.cpp:1278-1279
   I->replaceAllUsesWith(V);
-  I->eraseFromParent();
+  if (!I->mayHaveSideEffects())
+    I->eraseFromParent();
   ++NumSimplify;
----------------
Alternatively this could use `isInstructionTriviallyDead`. At that point `LoopUnswitch` should require `TLI` I guess and we should thread it properly in the pass. 
I don't mind doing that, FWIW, if you prefer and/or it's better.


https://reviews.llvm.org/D32664





More information about the llvm-commits mailing list