[llvm] [AArch64][GlobalISel] Don't crash when legalising vector G_SHL (PR #168848)
Nathan Corbyn via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 21 01:49:33 PST 2025
================
@@ -216,15 +216,15 @@ AArch64LegalizerInfo::AArch64LegalizerInfo(const AArch64Subtarget &ST)
.widenScalarToNextPow2(0)
.clampScalar(1, s32, s64)
.clampScalar(0, s32, s64)
+ .minScalarSameAs(1, 0)
+ .minScalarEltSameAsIf(isVector(0), 1, 0)
+ .maxScalarEltSameAsIf(isVector(0), 1, 0)
.clampNumElements(0, v8s8, v16s8)
.clampNumElements(0, v4s16, v8s16)
.clampNumElements(0, v2s32, v4s32)
.clampNumElements(0, v2s64, v2s64)
.moreElementsToNextPow2(0)
- .minScalarSameAs(1, 0)
- .scalarizeIf(scalarOrEltWiderThan(0, 64), 0)
- .minScalarEltSameAsIf(isVector(0), 1, 0)
- .maxScalarEltSameAsIf(isVector(0), 1, 0);
+ .scalarizeIf(scalarOrEltWiderThan(0, 64), 0);
----------------
cofibrant wrote:
Ok not sure I have a better fix... Basically the action responsible for padding vectors with more undef elements only accepts a single type to expand to, and when applied to binary operations naïvely uses this type for both input operands:
https://github.com/llvm/llvm-project/blob/59ed6dfe97b35a4dc88f69e3d830edf8caa99d10/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp#L6688-L6697
In other words, it assumes the inputs already agree on their scalar type. One option, I suppose, would be to have this code infer the number of elements from `MoreTy`, but inherit the scalar element types from each operand for each call to `moreElementsVector*()`. What do you think?
https://github.com/llvm/llvm-project/pull/168848
More information about the llvm-commits
mailing list