[llvm] [CodeGen] Fix EVT::changeVectorElementType assertion on simple-to-extended fallback (PR #173413)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Sun Dec 28 07:11:41 PST 2025


================
@@ -4261,10 +4261,8 @@ SDValue DAGCombiner::visitSUB(SDNode *N) {
     // sub 0, (and x, 1)  -->  SIGN_EXTEND_INREG x, i1
     if (N1.getOpcode() == ISD::AND && N1.hasOneUse() &&
         isOneOrOneSplat(N1->getOperand(1))) {
-      EVT ExtVT = EVT::getIntegerVT(*DAG.getContext(), 1);
-      if (VT.isVector())
-        ExtVT = EVT::getVectorVT(*DAG.getContext(), ExtVT,
-                                 VT.getVectorElementCount());
+      EVT ExtVT = VT.changeElementType(*DAG.getContext(),
+                                       EVT::getIntegerVT(*DAG.getContext(), 1));
----------------
RKSimon wrote:

Better to just use MVT::i1 directly instead of getIntegerVT?

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


More information about the llvm-commits mailing list