[PATCH] D157491: [NFC][LoopPredication] Add parsed checks logging
Aleksandr Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 10 04:24:00 PDT 2023
This revision was not accepted when it landed; it landed in state "Needs Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rGaa603c41caab: [NFC][LoopPredication] Add parsed checks logging (authored by aleksandr.popov).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D157491/new/
https://reviews.llvm.org/D157491
Files:
llvm/lib/Transforms/Scalar/LoopPredication.cpp
llvm/test/Transforms/LoopPredication/visited.ll
Index: llvm/test/Transforms/LoopPredication/visited.ll
===================================================================
--- llvm/test/Transforms/LoopPredication/visited.ll
+++ llvm/test/Transforms/LoopPredication/visited.ll
@@ -1,10 +1,15 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
-; RUN: opt -S -passes=loop-predication < %s 2>&1 | FileCheck %s
-; RUN: opt -S -passes='require<scalar-evolution>,loop-mssa(loop-predication)' -verify-memoryssa < %s 2>&1 | FileCheck %s
+; RUN: opt -S -passes=loop-predication -debug-only=loop-predication < %s 2>&1 | FileCheck %s
+; RUN: opt -S -passes='require<scalar-evolution>,loop-mssa(loop-predication)' -verify-memoryssa -debug-only=loop-predication < %s 2>&1 | FileCheck %s
+; REQUIRES: asserts
declare void @llvm.experimental.guard(i1, ...)
define i32 @test_visited(ptr %array, i32 %length, i32 %n, i32 %x) {
+; CHECK: Found checks:
+; CHECK-NEXT: %unrelated.cond = icmp eq i32 %x, %i
+; CHECK-NEXT: %within.bounds = icmp ult i32 %i, %length
+;
; CHECK-LABEL: @test_visited(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[TMP5:%.*]] = icmp eq i32 [[N:%.*]], 0
Index: llvm/lib/Transforms/Scalar/LoopPredication.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/LoopPredication.cpp
+++ llvm/lib/Transforms/Scalar/LoopPredication.cpp
@@ -767,14 +767,23 @@
return NumWidened;
}
-bool LoopPredication::widenGuardConditions(IntrinsicInst *Guard,
- SCEVExpander &Expander) {
+static SmallVector<Value *> extractChecksFromGuard(Instruction *Guard) {
LLVM_DEBUG(dbgs() << "Processing guard:\n");
LLVM_DEBUG(Guard->dump());
- TotalConsidered++;
SmallVector<Value *, 4> Checks;
parseWidenableGuard(Guard, Checks);
+ LLVM_DEBUG(dbgs() << "Found checks:\n");
+ std::for_each(Checks.begin(), Checks.end(), [](const Value *Check) {
+ LLVM_DEBUG(dbgs() << *Check << "\n");
+ });
+ return Checks;
+}
+
+bool LoopPredication::widenGuardConditions(IntrinsicInst *Guard,
+ SCEVExpander &Expander) {
+ TotalConsidered++;
+ auto Checks = extractChecksFromGuard(Guard);
unsigned NumWidened = widenChecks(Checks, Expander, Guard);
if (NumWidened == 0)
return false;
@@ -799,8 +808,6 @@
bool LoopPredication::widenWidenableBranchGuardConditions(
BranchInst *BI, SCEVExpander &Expander) {
assert(isGuardAsWidenableBranch(BI) && "Must be!");
- LLVM_DEBUG(dbgs() << "Processing guard:\n");
- LLVM_DEBUG(BI->dump());
Value *Cond, *WC;
BasicBlock *IfTrueBB, *IfFalseBB;
@@ -809,8 +816,7 @@
(void)Parsed;
TotalConsidered++;
- SmallVector<Value *, 4> Checks;
- parseWidenableGuard(BI, Checks);
+ auto Checks = extractChecksFromGuard(BI);
// At the moment, our matching logic for wideable conditions implicitly
// assumes we preserve the form: (br (and Cond, WC())). FIXME
Checks.push_back(WC);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D157491.548967.patch
Type: text/x-patch
Size: 2962 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230810/8e076451/attachment.bin>
More information about the llvm-commits
mailing list