Skip to content

Commit e66dfae

Browse files
authored
Merge branch 'main' into users/arsenm/amdgpu/test-vgpr-cd-selection-mfma-xf32
2 parents f57cbb5 + b663e56 commit e66dfae

File tree

8 files changed

+455
-44
lines changed

8 files changed

+455
-44
lines changed

clang/lib/Sema/SemaModule.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
#include "clang/AST/ASTConsumer.h"
1515
#include "clang/AST/ASTMutationListener.h"
16-
#include "clang/AST/RecursiveASTVisitor.h"
16+
#include "clang/AST/DynamicRecursiveASTVisitor.h"
1717
#include "clang/Lex/HeaderSearch.h"
1818
#include "clang/Lex/Preprocessor.h"
1919
#include "clang/Sema/ParsedAttr.h"
@@ -1422,14 +1422,14 @@ bool ExposureChecker::checkExposure(const CXXRecordDecl *RD, bool Diag) {
14221422
return IsExposure;
14231423
}
14241424

1425-
template <typename CallbackTy>
1426-
class ReferenceTULocalChecker
1427-
: public clang::RecursiveASTVisitor<ReferenceTULocalChecker<CallbackTy>> {
1425+
class ReferenceTULocalChecker : public DynamicRecursiveASTVisitor {
14281426
public:
1427+
using CallbackTy = std::function<void(DeclRefExpr *, ValueDecl *)>;
1428+
14291429
ReferenceTULocalChecker(ExposureChecker &C, CallbackTy &&Callback)
14301430
: Checker(C), Callback(std::move(Callback)) {}
14311431

1432-
bool VisitDeclRefExpr(DeclRefExpr *DRE) {
1432+
bool VisitDeclRefExpr(DeclRefExpr *DRE) override {
14331433
ValueDecl *Referenced = DRE->getDecl();
14341434
if (!Referenced)
14351435
return true;
@@ -1468,10 +1468,6 @@ class ReferenceTULocalChecker
14681468
CallbackTy Callback;
14691469
};
14701470

1471-
template <typename CallbackTy>
1472-
ReferenceTULocalChecker(ExposureChecker &, CallbackTy &&)
1473-
-> ReferenceTULocalChecker<CallbackTy>;
1474-
14751471
bool ExposureChecker::checkExposure(const Stmt *S, bool Diag) {
14761472
if (!S)
14771473
return false;

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2244,6 +2244,9 @@ static void transformRecipestoEVLRecipes(VPlan &Plan, VPValue &EVL) {
22442244

22452245
// Try to optimize header mask recipes away to their EVL variants.
22462246
for (VPValue *HeaderMask : collectAllHeaderMasks(Plan)) {
2247+
// TODO: Split optimizeMaskToEVL out and move into
2248+
// VPlanTransforms::optimize. transformRecipestoEVLRecipes should be run in
2249+
// tryToBuildVPlanWithVPRecipes beforehand.
22472250
for (VPUser *U : collectUsersRecursively(HeaderMask)) {
22482251
auto *CurRecipe = cast<VPRecipeBase>(U);
22492252
VPRecipeBase *EVLRecipe =
@@ -2265,6 +2268,20 @@ static void transformRecipestoEVLRecipes(VPlan &Plan, VPValue &EVL) {
22652268
}
22662269
ToErase.push_back(CurRecipe);
22672270
}
2271+
2272+
// Replace header masks with a mask equivalent to predicating by EVL:
2273+
//
2274+
// icmp ule widen-canonical-iv backedge-taken-count
2275+
// ->
2276+
// icmp ult step-vector, EVL
2277+
VPRecipeBase *EVLR = EVL.getDefiningRecipe();
2278+
VPBuilder Builder(EVLR->getParent(), std::next(EVLR->getIterator()));
2279+
Type *EVLType = TypeInfo.inferScalarType(&EVL);
2280+
VPValue *EVLMask = Builder.createICmp(
2281+
CmpInst::ICMP_ULT,
2282+
Builder.createNaryOp(VPInstruction::StepVector, {}, EVLType), &EVL);
2283+
HeaderMask->replaceAllUsesWith(EVLMask);
2284+
ToErase.push_back(HeaderMask->getDefiningRecipe());
22682285
}
22692286

22702287
for (VPRecipeBase *R : reverse(ToErase)) {

llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,8 @@ bool VPlanVerifier::verifyEVLRecipe(const VPInstruction &EVL) const {
171171
.Case<VPInstructionWithType>(
172172
[&](const VPInstructionWithType *S) { return VerifyEVLUse(*S, 0); })
173173
.Case<VPInstruction>([&](const VPInstruction *I) {
174-
if (I->getOpcode() == Instruction::PHI)
174+
if (I->getOpcode() == Instruction::PHI ||
175+
I->getOpcode() == Instruction::ICmp)
175176
return VerifyEVLUse(*I, 1);
176177
switch (I->getOpcode()) {
177178
case Instruction::Add:

0 commit comments

Comments
 (0)