[llvm] [VPlan] Add non-poison propagating LogicalAnd VPInstruction opcode. (PR #91897)

via llvm-commits llvm-commits at lists.llvm.org
Tue May 14 02:26:15 PDT 2024


================
@@ -8011,14 +8011,10 @@ VPValue *VPRecipeBuilder::createEdgeMask(BasicBlock *Src, BasicBlock *Dst) {
     EdgeMask = Builder.createNot(EdgeMask, BI->getDebugLoc());
 
   if (SrcMask) { // Otherwise block in-mask is all-one, no need to AND.
-    // The condition is 'SrcMask && EdgeMask', which is equivalent to
-    // 'select i1 SrcMask, i1 EdgeMask, i1 false'.
-    // The select version does not introduce new UB if SrcMask is false and
-    // EdgeMask is poison. Using 'and' here introduces undefined behavior.
-    VPValue *False = Plan.getOrAddLiveIn(
-        ConstantInt::getFalse(BI->getCondition()->getType()));
-    EdgeMask =
-        Builder.createSelect(SrcMask, EdgeMask, False, BI->getDebugLoc());
+    // Use LogicalAnd as it does not propagate poison, i.e. does not introduce
+    // new UB if SrcMask is false and EdgeMask is poison. Using 'and' here
+    // introduces undefined behavior.
----------------
ayalz wrote:

(nit, post-commit): above suggestion was a rephrasing of the initial comment, meant to replace it rather than augment it.

https://github.com/llvm/llvm-project/pull/91897


More information about the llvm-commits mailing list