[llvm] 418eee7 - [RISCV] Bail out of combineNarrowableShiftedLoad for types other than scalar int (#175011)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 8 08:52:36 PST 2026
Author: Alex Bradbury
Date: 2026-01-08T16:52:31Z
New Revision: 418eee7a92c83a6eabd5970ee432235cde17845a
URL: https://github.com/llvm/llvm-project/commit/418eee7a92c83a6eabd5970ee432235cde17845a
DIFF: https://github.com/llvm/llvm-project/commit/418eee7a92c83a6eabd5970ee432235cde17845a.diff
LOG: [RISCV] Bail out of combineNarrowableShiftedLoad for types other than scalar int (#175011)
Introduced in #170483 this was only ever meant to trigger for scalar
types. We get an error on rv32gcv for some inputs "Cannot implicitly
convert a scalable size to a fixed-width size in `TypeSize::operator
ScalarTy()`".
While we're editing this function, delete an accidentally repeated
comment.
Minimal reproducer:
```
define <vscale x 4 x ptr> @ham() {
bb:
%load = load <vscale x 4 x i32>, ptr null, align 4
%ashr = ashr <vscale x 4 x i32> %load, splat (i32 1)
%getelementptr = getelementptr i32, ptr null, <vscale x 4 x i32> %ashr
ret <vscale x 4 x ptr> %getelementptr
}
```
Added without test as the fix is trivial and the test is rather awkward/specialised. We will get coverage for this and similar issues from llvm-test-suite rv32gcv in CI.
Added:
Modified:
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index f87c45a77dc64..add1e71ca594e 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -16704,7 +16704,10 @@ static SDValue reduceANDOfAtomicLoad(SDNode *N,
// hidden by the intermediate shift. Detect that case and commute the
// shift/and in order to enable load narrowing.
static SDValue combineNarrowableShiftedLoad(SDNode *N, SelectionDAG &DAG) {
- // (and (shl (load ...), ShiftAmt), Mask)
+ EVT VT = N->getValueType(0);
+ if (!VT.isScalarInteger())
+ return SDValue();
+
using namespace SDPatternMatch;
SDValue LoadNode;
APInt MaskVal, ShiftVal;
@@ -16716,7 +16719,6 @@ static SDValue combineNarrowableShiftedLoad(SDNode *N, SelectionDAG &DAG) {
return SDValue();
}
- EVT VT = N->getValueType(0);
uint64_t ShiftAmt = ShiftVal.getZExtValue();
if (ShiftAmt >= VT.getSizeInBits())
More information about the llvm-commits
mailing list