[llvm] [DAGCombine] Fix crash caused by illegal InterVT in ForwardStoreValueToDirectLoad (PR #181175)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 12 08:33:36 PST 2026
https://github.com/Michael-Chen-NJU created https://github.com/llvm/llvm-project/pull/181175
This patch fixes an assertion failure in ForwardStoreValueToDirectLoad during DAGCombine.
The crash occurs when `STLF (Store-to-Load Forwarding)` creates an illegal intermediate bitcast type (e.g., `v128i1` when bridging a 128-bit store to a `<32 x i1>` load on X86). Since `v128i1` is not a legal mask type for the backend, it violates the expectations of the LegalizeDAG pass.
The fix adds a `TLI.isTypeLegal(InterVT)` check to ensure that the intermediate type used for the transformation is supported by the target.
Fixes #181130
>From 282956a57cbd16a7821d8c4bc6f81525a5d55aad Mon Sep 17 00:00:00 2001
From: Michael-Chen-NJU <2802328816 at qq.com>
Date: Fri, 13 Feb 2026 00:26:32 +0800
Subject: [PATCH] [DAGCombine] Fix crash caused by illegal InterVT in
ForwardStoreValueToDirectLoad
---
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 3 ++-
.../CodeGen/X86/stlf-v32i1-bitcast-crash.ll | 21 +++++++++++++++++++
2 files changed, 23 insertions(+), 1 deletion(-)
create mode 100644 llvm/test/CodeGen/X86/stlf-v32i1-bitcast-crash.ll
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 19bcdeeefb143..e513a16ee0e27 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -20831,7 +20831,8 @@ SDValue DAGCombiner::ForwardStoreValueToDirectLoad(LoadSDNode *LD) {
EVT InterVT = EVT::getVectorVT(*DAG.getContext(), EltVT,
StMemSize.divideCoefficientBy(EltSize));
- if (!TLI.isOperationLegalOrCustom(ISD::EXTRACT_SUBVECTOR, LDMemType))
+ if (!TLI.isOperationLegalOrCustom(ISD::EXTRACT_SUBVECTOR, LDMemType) ||
+ !TLI.isTypeLegal(InterVT))
break;
// In case of big-endian the offset is normalized to zero, denoting
diff --git a/llvm/test/CodeGen/X86/stlf-v32i1-bitcast-crash.ll b/llvm/test/CodeGen/X86/stlf-v32i1-bitcast-crash.ll
new file mode 100644
index 0000000000000..2abdc547dd479
--- /dev/null
+++ b/llvm/test/CodeGen/X86/stlf-v32i1-bitcast-crash.ll
@@ -0,0 +1,21 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 6
+; RUN: llc < %s -mtriple=x86_64-pc-windows-gnu -mcpu=tigerlake | FileCheck %s
+
+define <32 x i1> @v32i1_bitcast_crash(<4 x i8> %0) {
+; CHECK-LABEL: v32i1_bitcast_crash:
+; CHECK: # %bb.0:
+; CHECK-NEXT: subq $24, %rsp
+; CHECK-NEXT: .seh_stackalloc 24
+; CHECK-NEXT: .seh_endprologue
+; CHECK-NEXT: vmovaps (%rcx), %xmm0
+; CHECK-NEXT: vmovaps %xmm0, (%rsp)
+; CHECK-NEXT: kmovd (%rsp), %k0
+; CHECK-NEXT: vpmovm2b %k0, %ymm0
+; CHECK-NEXT: .seh_startepilogue
+; CHECK-NEXT: addq $24, %rsp
+; CHECK-NEXT: .seh_endepilogue
+; CHECK-NEXT: retq
+; CHECK-NEXT: .seh_endproc
+ %2 = bitcast <4 x i8> %0 to <32 x i1>
+ ret <32 x i1> %2
+}
More information about the llvm-commits
mailing list