Skip to content

Commit 70e8c98

Browse files
authored
[AArch64] Bail out for scalable vecs in areExtractShuffleVectors (#105484)
The added test triggers the following assert in `areExtractShuffleVectors` that is called from `shouldSinkOperands`: Assertion `(!isScalable() || isZero()) && "Request for a fixed element count on a scalable object"' failed. I don't think scalable types can be extract shuffles, so bail early if this is the case.
1 parent 5ddc79b commit 70e8c98

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

llvm/lib/Target/AArch64/AArch64ISelLowering.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16149,6 +16149,10 @@ static bool isSplatShuffle(Value *V) {
1614916149
/// or upper half of the vector elements.
1615016150
static bool areExtractShuffleVectors(Value *Op1, Value *Op2,
1615116151
bool AllowSplat = false) {
16152+
// Scalable types can't be extract shuffle vectors.
16153+
if (Op1->getType()->isScalableTy() || Op2->getType()->isScalableTy())
16154+
return false;
16155+
1615216156
auto areTypesHalfed = [](Value *FullV, Value *HalfV) {
1615316157
auto *FullTy = FullV->getType();
1615416158
auto *HalfTy = HalfV->getType();

llvm/test/Transforms/CodeGenPrepare/AArch64/sink-free-instructions.ll

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -984,3 +984,22 @@ if.else:
984984
ret <5 x float> %r.4
985985
}
986986

987+
; This ran in an assert in `areExtractShuffleVectors`.
988+
define <vscale x 8 x i16> @scalable_types_cannot_be_extract_shuffle() {
989+
; CHECK-LABEL: @scalable_types_cannot_be_extract_shuffle(
990+
; CHECK-NEXT: entry:
991+
; CHECK-NEXT: [[BROADCAST_SPLAT68:%.*]] = shufflevector <vscale x 8 x i8> zeroinitializer, <vscale x 8 x i8> poison, <vscale x 8 x i32> zeroinitializer
992+
; CHECK-NEXT: [[TMP0:%.*]] = zext <vscale x 8 x i8> [[BROADCAST_SPLAT68]] to <vscale x 8 x i16>
993+
; CHECK-NEXT: [[BROADCAST_SPLAT70:%.*]] = shufflevector <vscale x 8 x i8> zeroinitializer, <vscale x 8 x i8> poison, <vscale x 8 x i32> zeroinitializer
994+
; CHECK-NEXT: [[TMP1:%.*]] = zext <vscale x 8 x i8> [[BROADCAST_SPLAT70]] to <vscale x 8 x i16>
995+
; CHECK-NEXT: [[TMP2:%.*]] = sub <vscale x 8 x i16> [[TMP0]], [[TMP1]]
996+
; CHECK-NEXT: ret <vscale x 8 x i16> [[TMP2]]
997+
;
998+
entry:
999+
%broadcast.splat68 = shufflevector <vscale x 8 x i8> zeroinitializer, <vscale x 8 x i8> poison, <vscale x 8 x i32> zeroinitializer
1000+
%0 = zext <vscale x 8 x i8> %broadcast.splat68 to <vscale x 8 x i16>
1001+
%broadcast.splat70 = shufflevector <vscale x 8 x i8> zeroinitializer, <vscale x 8 x i8> poison, <vscale x 8 x i32> zeroinitializer
1002+
%1 = zext <vscale x 8 x i8> %broadcast.splat70 to <vscale x 8 x i16>
1003+
%2 = sub <vscale x 8 x i16> %0, %1
1004+
ret <vscale x 8 x i16> %2
1005+
}

0 commit comments

Comments
 (0)