Skip to content

Commit

Permalink
fixup! repond to @artagnon initial set of review
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelmaitland committed Aug 30, 2024
1 parent dba2a22 commit 51e4c67
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 43 deletions.
13 changes: 0 additions & 13 deletions llvm/lib/Transforms/Vectorize/VPlan.h
Original file line number Diff line number Diff line change
Expand Up @@ -3983,19 +3983,6 @@ class VPlanSlp {
bool isCompletelySLP() const { return CompletelySLP; }
};

namespace vputils {

/// Returns true for PHI-like recipes.
bool isPhi(const VPRecipeBase &R);

/// Returns true for PHI-like recipes that generate their own backedge
bool isPhiThatGeneratesBackedge(const VPRecipeBase &R);

/// Returns true for PHI-like recipes that exists in vector loop header basic
/// block
bool isHeaderPhi(const VPRecipeBase &R);
} // end namespace vputils

} // end namespace llvm

#endif // LLVM_TRANSFORMS_VECTORIZE_VPLAN_H
26 changes: 0 additions & 26 deletions llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3360,29 +3360,3 @@ void VPEVLBasedIVPHIRecipe::print(raw_ostream &O, const Twine &Indent,
}
#endif

bool vputils::isPhi(const VPRecipeBase &R) {
if (R.isPhi())
return true;
if (auto *VPInst = dyn_cast<VPInstruction>(&R))
return VPInst->getOpcode() == VPInstruction::CSAMaskPhi ||
VPInst->getOpcode() == VPInstruction::CSAVLPhi;
return false;
}

bool vputils::isPhiThatGeneratesBackedge(const VPRecipeBase &R) {
if (isa<VPWidenPHIRecipe, VPCSAHeaderPHIRecipe>(&R))
return true;
if (auto *VPInst = dyn_cast<VPInstruction>(&R))
return VPInst->getOpcode() == VPInstruction::CSAMaskPhi ||
VPInst->getOpcode() == VPInstruction::CSAVLPhi;
return false;
}

bool vputils::isHeaderPhi(const VPRecipeBase &R) {
if (isa<VPHeaderPHIRecipe, VPWidenPHIRecipe>(&R))
return true;
if (auto *VPInst = dyn_cast<VPInstruction>(&R))
return VPInst->getOpcode() == VPInstruction::CSAMaskPhi ||
VPInst->getOpcode() == VPInstruction::CSAVLPhi;
return false;
}
28 changes: 28 additions & 0 deletions llvm/lib/Transforms/Vectorize/VPlanUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,31 @@ bool vputils::isHeaderMask(const VPValue *V, VPlan &Plan) {
return match(V, m_Binary<Instruction::ICmp>(m_VPValue(A), m_VPValue(B))) &&
IsWideCanonicalIV(A) && B == Plan.getOrCreateBackedgeTakenCount();
}


bool vputils::isPhi(const VPRecipeBase &R) {
if (R.isPhi())
return true;
if (auto *VPInst = dyn_cast<VPInstruction>(&R))
return VPInst->getOpcode() == VPInstruction::CSAMaskPhi ||
VPInst->getOpcode() == VPInstruction::CSAVLPhi;
return false;
}

bool vputils::isPhiThatGeneratesBackedge(const VPRecipeBase &R) {
if (isa<VPWidenPHIRecipe, VPCSAHeaderPHIRecipe>(&R))
return true;
if (auto *VPInst = dyn_cast<VPInstruction>(&R))
return VPInst->getOpcode() == VPInstruction::CSAMaskPhi ||
VPInst->getOpcode() == VPInstruction::CSAVLPhi;
return false;
}

bool vputils::isHeaderPhi(const VPRecipeBase &R) {
if (isa<VPHeaderPHIRecipe, VPWidenPHIRecipe>(&R))
return true;
if (auto *VPInst = dyn_cast<VPInstruction>(&R))
return VPInst->getOpcode() == VPInstruction::CSAMaskPhi ||
VPInst->getOpcode() == VPInstruction::CSAVLPhi;
return false;
}
11 changes: 11 additions & 0 deletions llvm/lib/Transforms/Vectorize/VPlanUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,17 @@ inline bool isUniformAfterVectorization(const VPValue *VPV) {

/// Return true if \p V is a header mask in \p Plan.
bool isHeaderMask(const VPValue *V, VPlan &Plan);

/// Returns true for PHI-like recipes.
bool isPhi(const VPRecipeBase &R);

/// Returns true for PHI-like recipes that generate their own backedge
bool isPhiThatGeneratesBackedge(const VPRecipeBase &R);

/// Returns true for PHI-like recipes that exists in vector loop header basic
/// block
bool isHeaderPhi(const VPRecipeBase &R);

} // end namespace llvm::vputils

#endif
8 changes: 4 additions & 4 deletions llvm/test/Transforms/LoopVectorize/RISCV/csa.ll
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ for.body: ; preds = %for.body.preheader,
}

; This function is generated from the following C/C++ program:
; int simple_csa_int_select(int N, int *data) {
; int simple_csa_int_select_induction_cmp(int N, int *data) {
; int t = -1;
; for (int i = 0; i < N; i++) {
; if (i < data[i])
Expand Down Expand Up @@ -1373,13 +1373,13 @@ for.body: ; preds = %for.body.preheader,
}

; This function is generated from the following C/C++ program:
; int csa_in_series_int_select(int N, int *data0, int *data1) {
; int csa_in_series_int_select_induction_cmp(int N, int *data0, int *data1) {
; int t = -1;
; int s = -1;
; for (int i = 0; i < N; i++) {
; if (a < data0[i])
; if (i < data0[i])
; t = data0[i];
; if (a < data1[i])
; if (i < data1[i])
; s = data1[i];
; }
; return t | s; // use t and s
Expand Down

0 comments on commit 51e4c67

Please sign in to comment.