Skip to content

[VPlan] Treat Div/Rem as not Predicated if divisor is invariant #95191

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

eastB233
Copy link
Contributor

@eastB233 eastB233 commented Jun 12, 2024

It tries to fix #94328

From what I understand so far, as recorded in the issue, I think
we can treat Div/Rem as not Predicated if divisor is invariant.

@llvmbot
Copy link
Member

llvmbot commented Jun 12, 2024

@llvm/pr-subscribers-llvm-transforms

Author: None (eastB233)

Changes

It tries to fix #94328

From what I understand so far, as recorded in the issue, I think
an instruction that would be scalar after vectorization shoud be
marked as not predicated.


Full diff: https://github.com/llvm/llvm-project/pull/95191.diff

1 Files Affected:

  • (modified) llvm/lib/Transforms/Vectorize/LoopVectorize.cpp (+5-1)
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index c7c19ef456c7c..3c1520746c988 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -8326,7 +8326,11 @@ VPReplicateRecipe *VPRecipeBuilder::handleReplication(Instruction *I,
       [&](ElementCount VF) { return CM.isUniformAfterVectorization(I, VF); },
       Range);
 
-  bool IsPredicated = CM.isPredicatedInst(I);
+  bool IsPredicated = LoopVectorizationPlanner::getDecisionAndClampRange(
+      [&](ElementCount VF) {
+        return CM.isPredicatedInst(I) && !CM.isScalarAfterVectorization(I, VF);
+      },
+      Range);
 
   // Even if the instruction is not marked as uniform, there are certain
   // intrinsic calls that can be effectively treated as such, so we check for

@eastB233 eastB233 changed the title [VPlan] Mark Scalar instruction as not predicated [VPlan] Treat Div/Rem as not Predicated if divisor is invariant Jun 13, 2024
@eastB233
Copy link
Contributor Author

#94328 has been fixed by #98892

@eastB233 eastB233 closed this Jul 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[VPlan] Report "Assertion `!State->VF.isScalable() && "VF is assumed to be non scalable."' failed"
2 participants