[llvm] r339871 - [ARM] Ignore GEPs in ARMCodeGenPrepare
Sam Parker via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 16 05:24:40 PDT 2018
Author: sam_parker
Date: Thu Aug 16 05:24:40 2018
New Revision: 339871
URL: http://llvm.org/viewvc/llvm-project?rev=339871&view=rev
Log:
[ARM] Ignore GEPs in ARMCodeGenPrepare
While searching through the use-def tree, ignore GetElementPtrInst
instructions because they don't need promoting and neither do their
indices. Otherwise, the wide indices prevent the transformation from
happening.
Differential Revision: https://reviews.llvm.org/D50762
Modified:
llvm/trunk/lib/Target/ARM/ARMCodeGenPrepare.cpp
llvm/trunk/test/CodeGen/ARM/arm-cgp-pointers.ll
Modified: llvm/trunk/lib/Target/ARM/ARMCodeGenPrepare.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMCodeGenPrepare.cpp?rev=339871&r1=339870&r2=339871&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMCodeGenPrepare.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMCodeGenPrepare.cpp Thu Aug 16 05:24:40 2018
@@ -582,6 +582,11 @@ bool ARMCodeGenPrepare::TryToPromote(Val
if (CurrentVisited.count(V))
return true;
+ // Ignore GEPs because they don't need promoting and the constant indices
+ // will prevent the transformation.
+ if (isa<GetElementPtrInst>(V))
+ return true;
+
if (!isSupportedValue(V) || (shouldPromote(V) && !isLegalToPromote(V))) {
LLVM_DEBUG(dbgs() << "ARM CGP: Can't handle: " << *V << "\n");
return false;
Modified: llvm/trunk/test/CodeGen/ARM/arm-cgp-pointers.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/arm-cgp-pointers.ll?rev=339871&r1=339870&r2=339871&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/ARM/arm-cgp-pointers.ll (original)
+++ llvm/trunk/test/CodeGen/ARM/arm-cgp-pointers.ll Thu Aug 16 05:24:40 2018
@@ -82,3 +82,54 @@ entry:
%res = select i1 %cmp, i16 128, i16 255
ret i16 %res
}
+
+; CHECK-LABEL: gep_2d_array
+; CHECK-NOT: uxt
+define i8 @gep_2d_array(i8** %a, i8 zeroext %arg) {
+entry:
+ %arrayidx.us = getelementptr inbounds i8*, i8** %a, i32 0
+ %0 = load i8*, i8** %arrayidx.us, align 4
+ %1 = load i8, i8* %0, align 1
+ %sub = sub nuw i8 %1, 1
+ %cmp = icmp ult i8 %sub, %arg
+ %res = select i1 %cmp, i8 27, i8 54
+ ret i8 %res
+}
+
+; CHECK-LABEL: gep_2d_array_loop
+; CHECK-NOT: uxt
+define void @gep_2d_array_loop(i16** nocapture readonly %a, i16** nocapture readonly %b, i32 %N) {
+entry:
+ %cmp30 = icmp eq i32 %N, 0
+ br i1 %cmp30, label %for.cond.cleanup, label %for.cond1.preheader.us
+
+for.cond1.preheader.us:
+ %y.031.us = phi i32 [ %inc13.us, %for.cond1.for.cond.cleanup3_crit_edge.us ], [ 0, %entry ]
+ br label %for.body4.us
+
+for.body4.us:
+ %x.029.us = phi i32 [ 0, %for.cond1.preheader.us ], [ %inc.us, %for.body4.us ]
+ %arrayidx.us = getelementptr inbounds i16*, i16** %a, i32 %x.029.us
+ %0 = load i16*, i16** %arrayidx.us, align 4
+ %arrayidx5.us = getelementptr inbounds i16, i16* %0, i32 %y.031.us
+ %1 = load i16, i16* %arrayidx5.us, align 2
+ %dec.us = add nuw i16 %1, -1
+ %cmp6.us = icmp ult i16 %dec.us, 16383
+ %shl.us = shl nuw i16 %dec.us, 2
+ %spec.select.us = select i1 %cmp6.us, i16 %shl.us, i16 %dec.us
+ %arrayidx10.us = getelementptr inbounds i16*, i16** %b, i32 %x.029.us
+ %2 = load i16*, i16** %arrayidx10.us, align 4
+ %arrayidx11.us = getelementptr inbounds i16, i16* %2, i32 %y.031.us
+ store i16 %spec.select.us, i16* %arrayidx11.us, align 2
+ %inc.us = add nuw i32 %x.029.us, 1
+ %exitcond = icmp eq i32 %inc.us, %N
+ br i1 %exitcond, label %for.cond1.for.cond.cleanup3_crit_edge.us, label %for.body4.us
+
+for.cond1.for.cond.cleanup3_crit_edge.us:
+ %inc13.us = add nuw i32 %y.031.us, 1
+ %exitcond32 = icmp eq i32 %inc13.us, %N
+ br i1 %exitcond32, label %for.cond.cleanup, label %for.cond1.preheader.us
+
+for.cond.cleanup:
+ ret void
+}
More information about the llvm-commits
mailing list