[PATCH] Allow bitcast + struct GEP transform to work with addrspacecast

Reid Kleckner rnk at google.com
Mon Aug 11 16:59:07 PDT 2014


lgtm

================
Comment at: lib/Transforms/InstCombine/InstructionCombining.cpp:1678
@@ +1677,3 @@
+   ///   X = bitcast A addrspace(1)* to B addrspace(1)*
+   ///   Y = addrspacecast A addrspace(1)* to B addrspace(2)*
+   ///   Z = gep Y, <...constant indices...>
----------------
Indentation seems off, but it could be phab.

================
Comment at: lib/Transforms/InstCombine/InstructionCombining.cpp:1715
@@ +1714,3 @@
+
+        if (Operand->getType()->getPointerAddressSpace() == GEP.getAddressSpace())
+          return new BitCastInst(Operand, GEP.getType());
----------------
I guess it depends on your perspective, but I consider the addrspacecast case exceptional, so I'd handle it first and return early for it.

================
Comment at: lib/Transforms/InstCombine/InstructionCombining.cpp:1733
@@ +1732,3 @@
+
+        if (NGEP->getType()->getPointerAddressSpace() == GEP.getAddressSpace())
+          return new BitCastInst(NGEP, GEP.getType());
----------------
Ditto with this condition.

http://reviews.llvm.org/D4509






More information about the llvm-commits mailing list