[llvm] 0d1f853 - [X86] truncateVectorWithPACK - ensure we don't truncate to <1 x iXX> vector types

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 7 06:12:03 PDT 2023


Author: Simon Pilgrim
Date: 2023-08-07T14:11:42+01:00
New Revision: 0d1f8532bcde2a6001fb672d056673e1a6907187

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

LOG: [X86] truncateVectorWithPACK - ensure we don't truncate to <1 x iXX> vector types

Fuzz testing noticed that the sub-128-bit vector splitting added in ef4330f4f3cc didn't correctly halt at <2 x iXX> truncations.

Added: 
    

Modified: 
    llvm/lib/Target/X86/X86ISelLowering.cpp
    llvm/test/CodeGen/X86/vector-pack-128.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 38230ae7231bfd..06925ce45d1b0a 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -19983,7 +19983,7 @@ static SDValue truncateVectorWithPACK(unsigned Opcode, EVT DstVT, SDValue In,
     return In;
 
   unsigned NumElems = SrcVT.getVectorNumElements();
-  if (!isPowerOf2_32(NumElems))
+  if (NumElems < 2 || !isPowerOf2_32(NumElems) )
     return SDValue();
 
   unsigned DstSizeInBits = DstVT.getSizeInBits();

diff  --git a/llvm/test/CodeGen/X86/vector-pack-128.ll b/llvm/test/CodeGen/X86/vector-pack-128.ll
index a462b8b0c955de..d11e1a70b684cd 100644
--- a/llvm/test/CodeGen/X86/vector-pack-128.ll
+++ b/llvm/test/CodeGen/X86/vector-pack-128.ll
@@ -1,10 +1,10 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
-; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+sse2   | FileCheck %s --check-prefixes=SSE,SSE2
-; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+sse4.2 | FileCheck %s --check-prefixes=SSE,SSE4
-; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx    | FileCheck %s --check-prefixes=AVX,AVX1
-; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx2   | FileCheck %s --check-prefixes=AVX,AVX2
-; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx512vl,+avx512f  | FileCheck %s --check-prefixes=AVX,AVX512
-; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx512vl,+avx512bw | FileCheck %s --check-prefixes=AVX,AVX512
+; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+sse2   | FileCheck %s --check-prefixes=CHECK,SSE,SSE2
+; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+sse4.2 | FileCheck %s --check-prefixes=CHECK,SSE,SSE4
+; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx    | FileCheck %s --check-prefixes=CHECK,AVX,AVX1
+; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx2   | FileCheck %s --check-prefixes=CHECK,AVX,AVX2
+; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx512vl,+avx512f  | FileCheck %s --check-prefixes=CHECK,AVX,AVX512
+; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx512vl,+avx512bw | FileCheck %s --check-prefixes=CHECK,AVX,AVX512
 
 ; trunc(concat(x,y)) -> pack
 
@@ -322,5 +322,25 @@ define <16 x i8> @concat_trunc_packuswb_128(<8 x i16> %a0, <8 x i16> %a1) nounwi
   %5 = shufflevector <8 x i8> %3, <8 x i8> %4, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
   ret <16 x i8> %5
 }
+
+; Fuzz test - don't pack a v1i32 comparison result.
+define void @autogen_SD10339(<1 x i32> %I49) {
+; CHECK-LABEL: autogen_SD10339:
+; CHECK:       # %bb.0: # %BB
+; CHECK-NEXT:    .p2align 4, 0x90
+; CHECK-NEXT:  .LBB8_1: # %CF
+; CHECK-NEXT:    # =>This Inner Loop Header: Depth=1
+; CHECK-NEXT:    movw $1, 0
+; CHECK-NEXT:    jmp .LBB8_1
+BB:
+  %Cmp53 = icmp uge <1 x i32> %I49, zeroinitializer
+  br label %CF
+
+CF:                                               ; preds = %CF, %BB
+  %ZE166 = zext <1 x i1> %Cmp53 to <1 x i16>
+  store <1 x i16> %ZE166, ptr null, align 2
+  br label %CF
+}
+
 ;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
 ; AVX: {{.*}}


        


More information about the llvm-commits mailing list