From 8cf129fab9c45310ca121a2eb9a6e5e71cc5e5c1 Mon Sep 17 00:00:00 2001 From: David Sherwood Date: Wed, 18 Dec 2024 12:41:34 +0000 Subject: [PATCH 1/3] [LoopVectorize] Use new single string variant of reportVectorizationFailure --- .../Vectorize/LoopVectorizationLegality.cpp | 14 +------------- llvm/lib/Transforms/Vectorize/LoopVectorize.cpp | 2 -- .../X86/vectorization-remarks-missed.ll | 4 ++-- 3 files changed, 3 insertions(+), 17 deletions(-) diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp index 555c8435dd330..0c4b5cec3988d 100644 --- a/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp +++ b/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp @@ -666,7 +666,6 @@ bool LoopVectorizationLegality::canVectorizeOuterLoop() { // Check whether we are able to set up outer loop induction. if (!setupOuterLoopInductions()) { reportVectorizationFailure("Unsupported outer loop Phi(s)", - "Unsupported outer loop Phi(s)", "UnsupportedPhi", ORE, TheLoop); if (DoExtraAnalysis) Result = false; @@ -962,7 +961,6 @@ bool LoopVectorizationLegality::canVectorizeInstrs() { Type *T = ST->getValueOperand()->getType(); if (!VectorType::isValidElementType(T)) { reportVectorizationFailure("Store instruction cannot be vectorized", - "store instruction cannot be vectorized", "CantVectorizeStore", ORE, TheLoop, ST); return false; } @@ -975,7 +973,6 @@ bool LoopVectorizationLegality::canVectorizeInstrs() { assert(VecTy && "did not find vectorized version of stored type"); if (!TTI->isLegalNTStore(VecTy, ST->getAlign())) { reportVectorizationFailure( - "nontemporal store instruction cannot be vectorized", "nontemporal store instruction cannot be vectorized", "CantVectorizeNontemporalStore", ORE, TheLoop, ST); return false; @@ -990,7 +987,6 @@ bool LoopVectorizationLegality::canVectorizeInstrs() { assert(VecTy && "did not find vectorized version of load type"); if (!TTI->isLegalNTLoad(VecTy, LD->getAlign())) { reportVectorizationFailure( - "nontemporal load instruction cannot be vectorized", "nontemporal load instruction cannot be vectorized", "CantVectorizeNontemporalLoad", ORE, TheLoop, LD); return false; @@ -1020,7 +1016,6 @@ bool LoopVectorizationLegality::canVectorizeInstrs() { continue; } reportVectorizationFailure("Value cannot be used outside the loop", - "value cannot be used outside the loop", "ValueUsedOutsideLoop", ORE, TheLoop, &I); return false; } @@ -1442,7 +1437,6 @@ bool LoopVectorizationLegality::blockCanBePredicated( bool LoopVectorizationLegality::canVectorizeWithIfConvert() { if (!EnableIfConversion) { reportVectorizationFailure("If-conversion is disabled", - "if-conversion is disabled", "IfConversionDisabled", ORE, TheLoop); return false; @@ -1493,14 +1487,12 @@ bool LoopVectorizationLegality::canVectorizeWithIfConvert() { if (isa(BB->getTerminator())) { if (TheLoop->isLoopExiting(BB)) { reportVectorizationFailure("Loop contains an unsupported switch", - "loop contains an unsupported switch", "LoopContainsUnsupportedSwitch", ORE, TheLoop, BB->getTerminator()); return false; } } else if (!isa(BB->getTerminator())) { reportVectorizationFailure("Loop contains an unsupported terminator", - "loop contains an unsupported terminator", "LoopContainsUnsupportedTerminator", ORE, TheLoop, BB->getTerminator()); return false; @@ -1510,8 +1502,7 @@ bool LoopVectorizationLegality::canVectorizeWithIfConvert() { if (blockNeedsPredication(BB) && !blockCanBePredicated(BB, SafePointers, MaskedOp)) { reportVectorizationFailure( - "Control flow cannot be substituted for a select", - "control flow cannot be substituted for a select", "NoCFGForSelect", + "Control flow cannot be substituted for a select", "NoCFGForSelect", ORE, TheLoop, BB->getTerminator()); return false; } @@ -1700,8 +1691,6 @@ bool LoopVectorizationLegality::isVectorizableEarlyExitLoop() { return false; } else if (!IsSafeOperation(&I)) { reportVectorizationFailure("Early exit loop contains operations that " - "cannot be speculatively executed", - "Early exit loop contains operations that " "cannot be speculatively executed", "UnsafeOperationsEarlyExitLoop", ORE, TheLoop); @@ -1764,7 +1753,6 @@ bool LoopVectorizationLegality::canVectorize(bool UseVPlanNativePath) { if (!canVectorizeOuterLoop()) { reportVectorizationFailure("Unsupported outer loop", - "unsupported outer loop", "UnsupportedOuterLoop", ORE, TheLoop); // TODO: Implement DoExtraAnalysis when subsequent legal checks support diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp index a6acc710a34c8..a5a43c3c0f0e6 100644 --- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp +++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp @@ -4265,7 +4265,6 @@ LoopVectorizationCostModel::computeMaxVF(ElementCount UserVF, unsigned UserIC) { if (TC == 0) { reportVectorizationFailure( - "Unable to calculate the loop count due to complex control flow", "unable to calculate the loop count due to complex control flow", "UnknownLoopCountComplexCFG", ORE, TheLoop); return FixedScalableVFPair::getNone(); @@ -9350,7 +9349,6 @@ LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(VFRange &Range) { addExitUsersForFirstOrderRecurrences(*Plan, ExitUsersToFix); if (!addUsersInExitBlocks(*Plan, ExitUsersToFix)) { reportVectorizationFailure( - "Some exit values in loop with uncountable exit not supported yet", "Some exit values in loop with uncountable exit not supported yet", "UncountableEarlyExitLoopsUnsupportedExitValue", ORE, OrigLoop); return nullptr; diff --git a/llvm/test/Transforms/LoopVectorize/X86/vectorization-remarks-missed.ll b/llvm/test/Transforms/LoopVectorize/X86/vectorization-remarks-missed.ll index 99911b251c81e..4c0317e300f19 100644 --- a/llvm/test/Transforms/LoopVectorize/X86/vectorization-remarks-missed.ll +++ b/llvm/test/Transforms/LoopVectorize/X86/vectorization-remarks-missed.ll @@ -41,7 +41,7 @@ ; } ; return k; ; } -; CHECK: remark: source.cpp:29:7: loop not vectorized: control flow cannot be substituted for a select +; CHECK: remark: source.cpp:29:7: loop not vectorized: Control flow cannot be substituted for a select ; CHECK: remark: source.cpp:27:3: loop not vectorized ; YAML: --- !Analysis @@ -104,7 +104,7 @@ ; YAML-NEXT: Function: test_multiple_failures ; YAML-NEXT: Args: ; YAML-NEXT: - String: 'loop not vectorized: ' -; YAML-NEXT: - String: control flow cannot be substituted for a select +; YAML-NEXT: - String: Control flow cannot be substituted for a select ; YAML-NEXT: ... ; YAML-NEXT: --- !Analysis ; YAML-NEXT: Pass: loop-vectorize From 8e79f48fd2ba12445fc05f0c2db52ed59eea0c99 Mon Sep 17 00:00:00 2001 From: David Sherwood Date: Wed, 18 Dec 2024 16:17:13 +0000 Subject: [PATCH 2/3] Fix formatting --- llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp index 0c4b5cec3988d..3e84dae981896 100644 --- a/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp +++ b/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp @@ -1753,8 +1753,7 @@ bool LoopVectorizationLegality::canVectorize(bool UseVPlanNativePath) { if (!canVectorizeOuterLoop()) { reportVectorizationFailure("Unsupported outer loop", - "UnsupportedOuterLoop", - ORE, TheLoop); + "UnsupportedOuterLoop", ORE, TheLoop); // TODO: Implement DoExtraAnalysis when subsequent legal checks support // outer loops. return false; From 2c006b81cdd58d241fd82ba099b30f4b76cf7731 Mon Sep 17 00:00:00 2001 From: David Sherwood Date: Wed, 18 Dec 2024 16:29:08 +0000 Subject: [PATCH 3/3] Fix formatting (again) --- llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp index 3e84dae981896..1c82fd174dbec 100644 --- a/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp +++ b/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp @@ -1437,8 +1437,7 @@ bool LoopVectorizationLegality::blockCanBePredicated( bool LoopVectorizationLegality::canVectorizeWithIfConvert() { if (!EnableIfConversion) { reportVectorizationFailure("If-conversion is disabled", - "IfConversionDisabled", - ORE, TheLoop); + "IfConversionDisabled", ORE, TheLoop); return false; }