[llvm] 653b336 - [LegalizeVectorTypes] Don't emit VP_SELECT when widening MLOAD to VP_LOAD (#179478)

via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 3 23:11:36 PST 2026


Author: Luke Lau
Date: 2026-02-04T07:11:30Z
New Revision: 653b336e66db89650b767590fd850f340b8bc067

URL: https://github.com/llvm/llvm-project/commit/653b336e66db89650b767590fd850f340b8bc067
DIFF: https://github.com/llvm/llvm-project/commit/653b336e66db89650b767590fd850f340b8bc067.diff

LOG: [LegalizeVectorTypes] Don't emit VP_SELECT when widening MLOAD to VP_LOAD (#179478)

This is part of the work to remove trivial VP intrinsics.

When widening an MLOAD we may use a VP_LOAD if it's supported. We use a
VP_SELECT to merge in the passthru, but we don't check if it's supported
by the target. This changes it to just emit a regular VSELECT instead to
prevent crashing in that case, and a VP_MERGE to keep the lanes past EVL
poison.

Added: 
    

Modified: 
    llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
index 4db9c5d009ae8..1fd5166ec148a 100644
--- a/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
@@ -6604,11 +6604,14 @@ SDValue DAGTypeLegalizer::WidenVecRes_MLOAD(MaskedLoadSDNode *N) {
                       N->getMemoryVT(), N->getMemOperand());
     SDValue NewVal = NewLoad;
 
-    // Manually merge with vp.select
+    // Manually merge with vselect
     if (!N->getPassThru()->isUndef()) {
       assert(WidenVT.isScalableVector());
-      NewVal =
-          DAG.getNode(ISD::VP_SELECT, dl, WidenVT, Mask, NewVal, PassThru, EVL);
+      NewVal = DAG.getNode(ISD::VSELECT, dl, WidenVT, Mask, NewVal, PassThru);
+      // The lanes past EVL are poison.
+      NewVal = DAG.getNode(ISD::VP_MERGE, dl, WidenVT,
+                           DAG.getAllOnesConstant(dl, WideMaskVT), NewVal,
+                           DAG.getPOISON(WidenVT), EVL);
     }
 
     // Modified the chain - switch anything that used the old chain to use


        


More information about the llvm-commits mailing list