[llvm] [LoongArch] Fix invalid VEXTH combines for unsupported type extensions (PR #209725)

via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 15 19:41:51 PDT 2026


================
@@ -8512,7 +8517,18 @@ static SDValue performEXTENDCombine(SDNode *N, SelectionDAG &DAG,
     if (SDValue R = PromoteMaskArithmetic(SDValue(N, 0), DL, DAG, Subtarget))
       return R;
 
----------------
wangleiat wrote:

Would the following check be sufficient? That would avoid the unnecessary call in unsupported cases, which also avoids the associated argument-passing overhead. Am I missing any cases where this wouldn't be correct?
```diff
diff --git a/llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp b/llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
index 4c5bb28a5e42..e935d1e313da 100644
--- a/llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
+++ b/llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
@@ -8512,6 +8512,10 @@ static SDValue performEXTENDCombine(SDNode *N, SelectionDAG &DAG,
     if (SDValue R = PromoteMaskArithmetic(SDValue(N, 0), DL, DAG, Subtarget))
       return R;
 
+    if (!DAG.getTargetLoweringInfo().isTypeLegal(VT) ||
+        N->getValueSizeInBits(0) != N->getOperand(0).getValueSizeInBits() * 2)
+      return SDValue();
+
     if (SDValue R = matchHalfOf128BitLanes(N->getOperand(0), /*isLow=*/false)) {
       if (N->getOpcode() == ISD::SIGN_EXTEND)
         return DAG.getNode(LoongArchISD::VEXTH, DL, VT, R);
```

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


More information about the llvm-commits mailing list