<div dir="ltr">Ignoring the issue of neededness or not, we have a function to do this anyway, you would want to use ->stripPointerCasts(), not do it yourself :)<div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Apr 14, 2017 at 4:15 PM, Stanislav Mekhanoshin via Phabricator via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">rampitec created this revision.<br>
Herald added subscribers: nhaehnle, wdng, mzolotukhin.<br>
<br>
Repository:<br>
rL LLVM<br>
<br>
<a href="https://reviews.llvm.org/D32101" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D32101</a><br>
<br>
Files:<br>
lib/Transforms/Vectorize/<wbr>LoadStoreVectorizer.cpp<br>
test/Transforms/<wbr>LoadStoreVectorizer/AMDGPU/<wbr>gep-bitcast.ll<br>
<br>
<br>
Index: test/Transforms/<wbr>LoadStoreVectorizer/AMDGPU/<wbr>gep-bitcast.ll<br>
==============================<wbr>==============================<wbr>=======<br>
--- /dev/null<br>
+++ test/Transforms/<wbr>LoadStoreVectorizer/AMDGPU/<wbr>gep-bitcast.ll<br>
@@ -0,0 +1,27 @@<br>
+; RUN: opt -S -mtriple=amdgcn--amdhsa -load-store-vectorizer < %s | FileCheck %s<br>
+<br>
+; Check that vectorizer can find a GEP through bitcast<br>
+; CHECK: load <4 x i32><br>
+define void @vect_zext_bitcast_idx(float addrspace(1)* %arg1, i32 %base) {<br>
+ %add1 = add nuw i32 %base, 0<br>
+ %zext1 = zext i32 %add1 to i64<br>
+ %gep1 = getelementptr inbounds float, float addrspace(1)* %arg1, i64 %zext1<br>
+ %f2i1 = bitcast float addrspace(1)* %gep1 to i32 addrspace(1)*<br>
+ %load1 = load i32, i32 addrspace(1)* %f2i1, align 4<br>
+ %add2 = add nuw i32 %base, 1<br>
+ %zext2 = zext i32 %add2 to i64<br>
+ %gep2 = getelementptr inbounds float, float addrspace(1)* %arg1, i64 %zext2<br>
+ %f2i2 = bitcast float addrspace(1)* %gep2 to i32 addrspace(1)*<br>
+ %load2 = load i32, i32 addrspace(1)* %f2i2, align 4<br>
+ %add3 = add nuw i32 %base, 2<br>
+ %zext3 = zext i32 %add3 to i64<br>
+ %gep3 = getelementptr inbounds float, float addrspace(1)* %arg1, i64 %zext3<br>
+ %f2i3 = bitcast float addrspace(1)* %gep3 to i32 addrspace(1)*<br>
+ %load3 = load i32, i32 addrspace(1)* %f2i3, align 4<br>
+ %add4 = add nuw i32 %base, 3<br>
+ %zext4 = zext i32 %add4 to i64<br>
+ %gep4 = getelementptr inbounds float, float addrspace(1)* %arg1, i64 %zext4<br>
+ %f2i4 = bitcast float addrspace(1)* %gep4 to i32 addrspace(1)*<br>
+ %load4 = load i32, i32 addrspace(1)* %f2i4, align 4<br>
+ ret void<br>
+}<br>
Index: lib/Transforms/Vectorize/<wbr>LoadStoreVectorizer.cpp<br>
==============================<wbr>==============================<wbr>=======<br>
--- lib/Transforms/Vectorize/<wbr>LoadStoreVectorizer.cpp<br>
+++ lib/Transforms/Vectorize/<wbr>LoadStoreVectorizer.cpp<br>
@@ -283,8 +283,14 @@<br>
<br>
// Look through GEPs after checking they're the same except for the last<br>
// index.<br>
- GetElementPtrInst *GEPA = dyn_cast<GetElementPtrInst>(<wbr>getPointerOperand(A));<br>
- GetElementPtrInst *GEPB = dyn_cast<GetElementPtrInst>(<wbr>getPointerOperand(B));<br>
+ Value *SrcPTRA = getPointerOperand(A);<br>
+ Value *SrcPTRB = getPointerOperand(B);<br>
+ while (auto *C = dyn_cast<BitCastInst>(SrcPTRA)<wbr>)<br>
+ SrcPTRA = C->getOperand(0);<br>
+ while (auto *C = dyn_cast<BitCastInst>(SrcPTRB)<wbr>)<br>
+ SrcPTRB = C->getOperand(0);<br>
+ GetElementPtrInst *GEPA = dyn_cast<GetElementPtrInst>(<wbr>SrcPTRA);<br>
+ GetElementPtrInst *GEPB = dyn_cast<GetElementPtrInst>(<wbr>SrcPTRB);<br>
if (!GEPA || !GEPB || GEPA->getNumOperands() != GEPB->getNumOperands())<br>
return false;<br>
unsigned FinalIndex = GEPA->getNumOperands() - 1;<br>
<br>
<br>
<br>______________________________<wbr>_________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-commits</a><br>
<br></blockquote></div><br></div>