Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit 36713c2

Browse files
committed
[AArch64] Fix assertion failure caused by an invalid comparison between APInt values.
APInt only knows how to compare values with the same BitWidth and asserts in all other cases. With this fix, function PerformORCombine does not use the APInt equality operator if the APInt values returned by 'isConstantSplat' differ in BitWidth. In that case they are different and no comparison is needed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199119 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 286cc13 commit 36713c2

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

lib/Target/AArch64/AArch64ISelLowering.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3476,8 +3476,9 @@ static SDValue PerformORCombine(SDNode *N,
34763476
BuildVectorSDNode *BVN1 = dyn_cast<BuildVectorSDNode>(N1->getOperand(1));
34773477
APInt SplatBits1;
34783478
if (BVN1 && BVN1->isConstantSplat(SplatBits1, SplatUndef, SplatBitSize,
3479-
HasAnyUndefs) &&
3480-
!HasAnyUndefs && SplatBits0 == ~SplatBits1) {
3479+
HasAnyUndefs) && !HasAnyUndefs &&
3480+
SplatBits0.getBitWidth() == SplatBits1.getBitWidth() &&
3481+
SplatBits0 == ~SplatBits1) {
34813482

34823483
return DAG.getNode(ISD::VSELECT, DL, VT, N0->getOperand(1),
34833484
N0->getOperand(0), N1->getOperand(0));
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
; RUN: llc < %s -mtriple=aarch64-none-linux-gnu -mattr=+neon | FileCheck %s
2+
3+
; Check that the DAGCombiner does not crash with an assertion failure
4+
; when performing a target specific combine to simplify a 'or' dag node
5+
; according to the following rule:
6+
; (or (and B, A), (and C, ~A)) => (VBSL A, B, C)
7+
; The assertion failure was caused by an invalid comparison between APInt
8+
; values with different 'BitWidth'.
9+
10+
define <8 x i8> @test1(<8 x i8> %a, <8 x i8> %b) {
11+
%tmp1 = and <8 x i8> %a, < i8 -1, i8 -1, i8 0, i8 0, i8 -1, i8 -1, i8 0, i8 0 >
12+
%tmp2 = and <8 x i8> %b, < i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0 >
13+
%tmp3 = or <8 x i8> %tmp1, %tmp2
14+
ret <8 x i8> %tmp3
15+
}
16+
17+
; CHECK-LABEL: test1
18+
; CHECK: ret
19+
20+
define <16 x i8> @test2(<16 x i8> %a, <16 x i8> %b) {
21+
%tmp1 = and <16 x i8> %a, < i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1 >
22+
%tmp2 = and <16 x i8> %b, < i8 -1, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0 >
23+
%tmp3 = or <16 x i8> %tmp1, %tmp2
24+
ret <16 x i8> %tmp3
25+
}
26+
27+
; CHECK-LABEL: test2
28+
; CHECK: ret
29+

0 commit comments

Comments
 (0)