Skip to content

Commit

Permalink
[DAG] Ensure Legal BUILD_VECTOR elements types in shuffle->And combine
Browse files Browse the repository at this point in the history
D129150 added a combine from shuffles to And that creates a BUILD_VECTOR
of constant elements. We need to ensure that the elements are of a legal
type, to prevent asserts during lowering.

Fixes #56970.

Differential Revision: https://reviews.llvm.org/D131350
  • Loading branch information
davemgreen committed Aug 8, 2022
1 parent a6dec9f commit 061e018
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22763,6 +22763,7 @@ SDValue DAGCombiner::visitVECTOR_SHUFFLE(SDNode *N) {
SDLoc DL(N);
EVT IntVT = VT.changeVectorElementTypeToInteger();
EVT IntSVT = VT.getVectorElementType().changeTypeToInteger();
IntSVT = TLI.getTypeToTransformTo(*DAG.getContext(), IntSVT);
SDValue ZeroElt = DAG.getConstant(0, DL, IntSVT);
SDValue AllOnesElt = DAG.getAllOnesConstant(DL, IntSVT);
SmallVector<SDValue, 16> AndMask(NumElts, DAG.getUNDEF(IntSVT));
Expand Down
22 changes: 22 additions & 0 deletions llvm/test/CodeGen/ARM/vector-store.ll
Original file line number Diff line number Diff line change
Expand Up @@ -397,3 +397,25 @@ define <4 x i32>* @test_vst1_1reg(<4 x i32>* %ptr.in, <4 x i32>* %ptr.out) {
%next = getelementptr <4 x i32>, <4 x i32>* %ptr.out, i32 2
ret <4 x i32>* %next
}

; PR56970
define void @v3i8store(<3 x i8> *%p) {
; CHECK-LABEL: v3i8store:
; CHECK: @ %bb.0:
; CHECK-NEXT: sub sp, #4
; CHECK-NEXT: vmov.i32 d16, #0xff
; CHECK-NEXT: mov r1, sp
; CHECK-NEXT: vmov.i32 d17, #0x0
; CHECK-NEXT: movs r2, #0
; CHECK-NEXT: vand d16, d17, d16
; CHECK-NEXT: vst1.32 {d16[0]}, [r1:32]
; CHECK-NEXT: vld1.32 {d16[0]}, [r1:32]
; CHECK-NEXT: vmovl.u16 q8, d16
; CHECK-NEXT: strb r2, [r0, #2]
; CHECK-NEXT: vmov.32 r1, d16[0]
; CHECK-NEXT: strh r1, [r0]
; CHECK-NEXT: add sp, #4
; CHECK-NEXT: bx lr
store <3 x i8> zeroinitializer, <3 x i8> *%p, align 4
ret void
}

0 comments on commit 061e018

Please sign in to comment.