[PATCH] D51698: Prevent Constant Folding From Optimizing inrange GEP

Peter Collingbourne via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 5 11:54:23 PDT 2018


pcc added a subscriber: llvm-commits.
pcc added inline comments.


================
Comment at: llvm/lib/Analysis/ConstantFolding.cpp:991
 /// etc information, due to only being passed an opcode and operands. Constant
 /// folding using this function strips this information.
 ///
----------------
I think this TODO is no longer accurate: we *are* being passed the instruction/constant in `InstOrCE` , so we end up preserving inbounds and inrange and could preserve nsw/nuw if we chose. I would remove it.


================
Comment at: llvm/lib/Analysis/ConstantFolding.cpp:1008
+    // Do not optimize inrange GEPs
+    if (GEP->getInRangeIndex() != None)
+      return nullptr;
----------------
Can this check be moved here?
http://llvm-cs.pcc.me.uk/lib/Analysis/ConstantFolding.cpp#957
I was imagining that if we fail to preserve inrange then we would return nullptr instead of dropping it.


https://reviews.llvm.org/D51698





More information about the llvm-commits mailing list