[PATCH] D109631: [HardwareLoops] Loop guard intrinsic to recognise zext
Sam Parker via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 16 00:33:49 PDT 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc98a8a09b5eb: [HardwareLoops] Loop guard intrinsic to recognise zext (authored by samparker).
Changed prior to commit:
https://reviews.llvm.org/D109631?vs=372276&id=372874#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D109631/new/
https://reviews.llvm.org/D109631
Files:
llvm/lib/CodeGen/HardwareLoops.cpp
llvm/test/Transforms/HardwareLoops/loop-guards.ll
Index: llvm/test/Transforms/HardwareLoops/loop-guards.ll
===================================================================
--- llvm/test/Transforms/HardwareLoops/loop-guards.ll
+++ llvm/test/Transforms/HardwareLoops/loop-guards.ll
@@ -348,3 +348,32 @@
if.end: ; preds = %do.body, %entry
ret void
}
+
+; CHECK-LABEL: test12
+; CHECK: entry:
+; CHECK-EXIT: [[TEST:%[^ ]+]] = call i1 @llvm.test.set.loop.iterations.i32(i32 %conv)
+; CHECK-LATCH: [[TEST1:%[^ ]+]] = call { i32, i1 } @llvm.test.start.loop.iterations.i32(i32 %conv)
+; CHECK-LATCH: [[TEST:%[^ ]+]] = extractvalue { i32, i1 } [[TEST1]], 1
+; CHECK: br i1 [[TEST]], label %for.body.preheader, label %for.end
+; CHECK: for.body.preheader:
+; CHECK: br label %for.body
+
+define void @test12(i32* nocapture %a, i32* nocapture readonly %b, i16 zeroext %length) {
+entry:
+ %conv = zext i16 %length to i32
+ %cmp8.not = icmp eq i16 %length, 0
+ br i1 %cmp8.not, label %for.end, label %for.body
+
+for.body: ; preds = %entry, %for.body
+ %i.09 = phi i32 [ %inc, %for.body ], [ 0, %entry ]
+ %arrayidx = getelementptr inbounds i32, i32* %b, i32 %i.09
+ %0 = load i32, i32* %arrayidx, align 4
+ %arrayidx2 = getelementptr inbounds i32, i32* %a, i32 %i.09
+ store i32 %0, i32* %arrayidx2, align 4
+ %inc = add nuw nsw i32 %i.09, 1
+ %exitcond.not = icmp eq i32 %inc, %conv
+ br i1 %exitcond.not, label %for.end, label %for.body
+
+for.end: ; preds = %for.body, %entry
+ ret void
+}
Index: llvm/lib/CodeGen/HardwareLoops.cpp
===================================================================
--- llvm/lib/CodeGen/HardwareLoops.cpp
+++ llvm/lib/CodeGen/HardwareLoops.cpp
@@ -365,7 +365,13 @@
return false;
};
- if (!IsCompareZero(ICmp, Count, 0) && !IsCompareZero(ICmp, Count, 1))
+ // Check if Count is a zext.
+ Value *CountBefZext =
+ isa<ZExtInst>(Count) ? cast<ZExtInst>(Count)->getOperand(0) : nullptr;
+
+ if (!IsCompareZero(ICmp, Count, 0) && !IsCompareZero(ICmp, Count, 1) &&
+ !IsCompareZero(ICmp, CountBefZext, 0) &&
+ !IsCompareZero(ICmp, CountBefZext, 1))
return false;
unsigned SuccIdx = ICmp->getPredicate() == ICmpInst::ICMP_NE ? 0 : 1;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109631.372874.patch
Type: text/x-patch
Size: 2292 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210916/c8706d10/attachment.bin>
More information about the llvm-commits
mailing list