[llvm-branch-commits] [llvm] bcd9043 - [DAG] Ensure Legal BUILD_VECTOR elements types in shuffle->And combine

Tobias Hieta via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Aug 10 01:59:32 PDT 2022


Author: David Green
Date: 2022-08-10T10:58:53+02:00
New Revision: bcd9043ccc96512ff97bb140a1ddc5b8e82902c3

URL: https://github.com/llvm/llvm-project/commit/bcd9043ccc96512ff97bb140a1ddc5b8e82902c3
DIFF: https://github.com/llvm/llvm-project/commit/bcd9043ccc96512ff97bb140a1ddc5b8e82902c3.diff

LOG: [DAG] Ensure Legal BUILD_VECTOR elements types in shuffle->And combine

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

(cherry picked from commit 061e0189a3dab6b1831a80d489ff1b15ad93aafb)

Added: 
    

Modified: 
    llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
    llvm/test/CodeGen/ARM/vector-store.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 154a3ef63613..8d465b9520de 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -22729,6 +22729,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));

diff  --git a/llvm/test/CodeGen/ARM/vector-store.ll b/llvm/test/CodeGen/ARM/vector-store.ll
index 30e2dddac06b..d099a9878405 100644
--- a/llvm/test/CodeGen/ARM/vector-store.ll
+++ b/llvm/test/CodeGen/ARM/vector-store.ll
@@ -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
+}


        


More information about the llvm-branch-commits mailing list