[PATCH] D68244: [InstCombine] don't assume 'inbounds' for bitcast pointer to GEP transform (PR43501)

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 2 09:43:14 PDT 2019


lebedev.ri added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp:2351
+          DerefBytes >= EltBitWidth / 8)
+        GEP->setIsInBounds();
+      return GEP;
----------------
jdoerfert wrote:
> Why all this logic? `bitcast` -> `gep inbounds 0, 0` should be fine as long as the pointer is `null` or points into (or to the end of) an allocated object.
> 
> @lebedev.ri 
> We can add an attribute to add `inbounds` to GEPs if we determine the above condition easily, I'll keep you posted. Open a bug if you want to make sure ;)
> Why all this logic? bitcast -> gep inbounds 0, 0 should be fine as long as the pointer is null or points into (or to the end of) an allocated object.

We don't know that the input is inbounds, see https://bugs.llvm.org/show_bug.cgi?id=43501
Or is there any such requirement for `bitcast`?


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

https://reviews.llvm.org/D68244





More information about the llvm-commits mailing list