[PATCH] D149310: [LegalizeVectorOps] Use all ones mask when expanding i1 VP_SELECT.

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 26 16:51:22 PDT 2023


craig.topper created this revision.
craig.topper added reviewers: reames, frasercrmck, rogfer01, kito-cheng, fakepaper56.
Herald added subscribers: luismarques, s.egerton, PkmX, simoncook, hiraditya, arichardson.
Herald added a project: All.
craig.topper requested review of this revision.
Herald added a project: LLVM.

We were previously using the condition as the mask. By the semantics
of VP operations, that means that anywhere the condition is false
returns poison and not the false operand.

Use an all ones mask instead.

No tests are affected because RISC-V drops the mask when lowering.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149310

Files:
  llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp


Index: llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp
+++ llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp
@@ -1304,11 +1304,11 @@
     return DAG.UnrollVectorOp(Node);
 
   SDValue Ones = DAG.getAllOnesConstant(DL, VT);
-  SDValue NotMask = DAG.getNode(ISD::VP_XOR, DL, VT, Mask, Ones, Mask, EVL);
+  SDValue NotMask = DAG.getNode(ISD::VP_XOR, DL, VT, Mask, Ones, Ones, EVL);
 
-  Op1 = DAG.getNode(ISD::VP_AND, DL, VT, Op1, Mask, Mask, EVL);
-  Op2 = DAG.getNode(ISD::VP_AND, DL, VT, Op2, NotMask, Mask, EVL);
-  return DAG.getNode(ISD::VP_OR, DL, VT, Op1, Op2, Mask, EVL);
+  Op1 = DAG.getNode(ISD::VP_AND, DL, VT, Op1, Mask, Ones, EVL);
+  Op2 = DAG.getNode(ISD::VP_AND, DL, VT, Op2, NotMask, Ones, EVL);
+  return DAG.getNode(ISD::VP_OR, DL, VT, Op1, Op2, Ones, EVL);
 }
 
 SDValue VectorLegalizer::ExpandVP_MERGE(SDNode *Node) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D149310.517391.patch
Type: text/x-patch
Size: 967 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230426/118fc4c0/attachment.bin>


More information about the llvm-commits mailing list