From: Craig Topper Date: Thu, 27 Apr 2023 15:26:11 +0000 (-0700) Subject: [LegalizeVectorOps] Use all ones mask when expanding i1 VP_SELECT. X-Git-Tag: upstream/17.0.6~10176 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0b5396b163b6ba014679a6af365747303b95cf97;p=platform%2Fupstream%2Fllvm.git [LegalizeVectorOps] Use all ones mask when expanding i1 VP_SELECT. 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. Reviewed By: fakepaper56 Differential Revision: https://reviews.llvm.org/D149310 --- diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp index e245b3c..18c5fc6 100644 --- a/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp @@ -1304,11 +1304,11 @@ SDValue VectorLegalizer::ExpandVP_SELECT(SDNode *Node) { 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) {