Skip to content

Commit 91a48e0

Browse files
committed
[AArch64][GlobalISel] Implicitly truncate APInt in matchExt combine.
The APInt using FirstRealElt + 1 is intended to match the next element, which might overflow the size of MaskBits. This prevents a new assert in APInt from triggering.
1 parent c8f3373 commit 91a48e0

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

llvm/lib/Target/AArch64/GISel/AArch64PostLegalizerLowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ std::optional<std::pair<bool, uint64_t>> getExtMask(ArrayRef<int> M,
9090

9191
// Use APInt to handle overflow when calculating expected element.
9292
unsigned MaskBits = APInt(32, NumElts * 2).logBase2();
93-
APInt ExpectedElt = APInt(MaskBits, *FirstRealElt + 1);
93+
APInt ExpectedElt = APInt(MaskBits, *FirstRealElt + 1, false, true);
9494

9595
// The following shuffle indices must be the successive elements after the
9696
// first real element.

llvm/test/CodeGen/AArch64/arm64-ext.ll

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,12 @@ define <4 x i16> @test_undef(<8 x i16> %tmp1, <8 x i16> %tmp2) {
122122
%tmp3 = shufflevector <8 x i16> %tmp1, <8 x i16> %tmp2, <4 x i32> <i32 undef, i32 8, i32 5, i32 9>
123123
ret <4 x i16> %tmp3
124124
}
125+
126+
define <2 x i64> @test_v2s64(<2 x i64> %a, <2 x i64> %b) {
127+
; CHECK-LABEL: test_v2s64:
128+
; CHECK: // %bb.0:
129+
; CHECK-NEXT: ext v0.16b, v1.16b, v0.16b, #8
130+
; CHECK-NEXT: ret
131+
%s = shufflevector <2 x i64> %a, <2 x i64> %b, <2 x i32> <i32 3, i32 0>
132+
ret <2 x i64> %s
133+
}

0 commit comments

Comments
 (0)