[PATCH] D66575: [AlignmentFromAssumptions] getNewAlignmentDiff(): use getURemExpr()
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 22 19:19:38 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL369723: [AlignmentFromAssumptions] getNewAlignmentDiff(): use getURemExpr() (authored by MaskRay, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D66575?vs=216604&id=216758#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D66575/new/
https://reviews.llvm.org/D66575
Files:
llvm/trunk/lib/Transforms/Scalar/AlignmentFromAssumptions.cpp
llvm/trunk/test/Transforms/AlignmentFromAssumptions/simple.ll
Index: llvm/trunk/lib/Transforms/Scalar/AlignmentFromAssumptions.cpp
===================================================================
--- llvm/trunk/lib/Transforms/Scalar/AlignmentFromAssumptions.cpp
+++ llvm/trunk/lib/Transforms/Scalar/AlignmentFromAssumptions.cpp
@@ -93,9 +93,7 @@
const SCEV *AlignSCEV,
ScalarEvolution *SE) {
// DiffUnits = Diff % int64_t(Alignment)
- const SCEV *DiffAlignDiv = SE->getUDivExpr(DiffSCEV, AlignSCEV);
- const SCEV *DiffAlign = SE->getMulExpr(DiffAlignDiv, AlignSCEV);
- const SCEV *DiffUnitsSCEV = SE->getMinusSCEV(DiffAlign, DiffSCEV);
+ const SCEV *DiffUnitsSCEV = SE->getURemExpr(DiffSCEV, AlignSCEV);
LLVM_DEBUG(dbgs() << "\talignment relative to " << *AlignSCEV << " is "
<< *DiffUnitsSCEV << " (diff: " << *DiffSCEV << ")\n");
Index: llvm/trunk/test/Transforms/AlignmentFromAssumptions/simple.ll
===================================================================
--- llvm/trunk/test/Transforms/AlignmentFromAssumptions/simple.ll
+++ llvm/trunk/test/Transforms/AlignmentFromAssumptions/simple.ll
@@ -90,6 +90,61 @@
; CHECK: ret i32 %add.lcssa
}
+; test D66575
+; def hoo2(a, id, num):
+; for i0 in range(id*64, 4096, num*64):
+; for i1 in range(0, 4096, 32):
+; for i2 in range(0, 4096, 32):
+; load(a, i0+i1+i2+32)
+define void @hoo2(i32* nocapture %a, i64 %id, i64 %num) nounwind uwtable readonly {
+entry:
+ %ptrint = ptrtoint i32* %a to i64
+ %maskedptr = and i64 %ptrint, 31
+ %maskcond = icmp eq i64 %maskedptr, 0
+ tail call void @llvm.assume(i1 %maskcond)
+ %id.mul = shl nsw i64 %id, 6
+ %num.mul = shl nsw i64 %num, 6
+ br label %for0.body
+
+for0.body:
+ %i0 = phi i64 [ %id.mul, %entry ], [ %i0.next, %for0.end ]
+ br label %for1.body
+
+for1.body:
+ %i1 = phi i64 [ 0, %for0.body ], [ %i1.next, %for1.end ]
+ br label %for2.body
+
+for2.body:
+ %i2 = phi i64 [ 0, %for1.body ], [ %i2.next, %for2.body ]
+
+ %t1 = add nuw nsw i64 %i0, %i1
+ %t2 = add nuw nsw i64 %t1, %i2
+ %t3 = add nuw nsw i64 %t2, 32
+ %arrayidx = getelementptr inbounds i32, i32* %a, i64 %t3
+ %x = load i32, i32* %arrayidx, align 4
+
+ %i2.next = add nuw nsw i64 %i2, 32
+ %cmp2 = icmp ult i64 %i2.next, 4096
+ br i1 %cmp2, label %for2.body, label %for1.end
+
+for1.end:
+ %i1.next = add nuw nsw i64 %i1, 32
+ %cmp1 = icmp ult i64 %i1.next, 4096
+ br i1 %cmp1, label %for1.body, label %for0.end
+
+for0.end:
+ %i0.next = add nuw nsw i64 %i0, %num.mul
+ %cmp0 = icmp ult i64 %i0.next, 4096
+ br i1 %cmp0, label %for0.body, label %return
+
+return:
+ ret void
+
+; CHECK-LABEL: @hoo2
+; CHECK: load i32, i32* %arrayidx, align 32
+; CHECK: ret void
+}
+
define i32 @joo(i32* nocapture %a) nounwind uwtable readonly {
entry:
%ptrint = ptrtoint i32* %a to i64
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D66575.216758.patch
Type: text/x-patch
Size: 2848 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190823/a9f249b4/attachment.bin>
More information about the llvm-commits
mailing list