[PATCH] D31924: SROA: Allow eliminating addrspacecasted allocas

Matt Arsenault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 20 13:45:08 PDT 2017


arsenm added inline comments.


================
Comment at: lib/Transforms/Scalar/SROA.cpp:1557
+    unsigned Opc = Operator::getOpcode(Ptr);
+    if (Opc == Instruction::BitCast || Opc == Instruction::AddrSpaceCast) {
       Ptr = cast<Operator>(Ptr)->getOperand(0);
----------------
sanjoy wrote:
> Are you ruling that `GEP(CAST(X), 1)` is the same as `CAST(GEP X, 1)`?  If so, I'm not sure this is correct given your constraint on address space casts.
> 
> For instance, if casting from address space N to M, with both spaces having the same pointer width, involves flipping the high and low halves of the pointer then `GEP(CAST(X), 1)` is not the same as `(CAST(GEP X, 1))`.
> 
> Of course, this means that GEPs over pointers of address space M are different operations from GEPs over pointers of address space N, but that's allowed, AFAIK.
> 
Yes, those should be the same


https://reviews.llvm.org/D31924





More information about the llvm-commits mailing list