[llvm] 75d52f5 - [X86] matchTruncateWithPACK - merge equivalent calls to getSizeInBits/getScalarSizeInBits. NFC.
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 29 02:47:00 PDT 2024
Author: Simon Pilgrim
Date: 2024-04-29T10:36:20+01:00
New Revision: 75d52f5797c367488c5623fefb02b32dea25fbb1
URL: https://github.com/llvm/llvm-project/commit/75d52f5797c367488c5623fefb02b32dea25fbb1
DIFF: https://github.com/llvm/llvm-project/commit/75d52f5797c367488c5623fefb02b32dea25fbb1.diff
LOG: [X86] matchTruncateWithPACK - merge equivalent calls to getSizeInBits/getScalarSizeInBits. NFC.
Added:
Modified:
llvm/lib/Target/X86/X86ISelLowering.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 82d3859225fdf7..3dca306a7642c9 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -20394,14 +20394,16 @@ static SDValue matchTruncateWithPACK(unsigned &PackOpcode, EVT DstVT,
EVT SrcVT = In.getValueType();
EVT DstSVT = DstVT.getVectorElementType();
EVT SrcSVT = SrcVT.getVectorElementType();
+ unsigned NumDstEltBits = DstSVT.getSizeInBits();
+ unsigned NumSrcEltBits = SrcSVT.getSizeInBits();
// Check we have a truncation suited for PACKSS/PACKUS.
if (!((SrcSVT == MVT::i16 || SrcSVT == MVT::i32 || SrcSVT == MVT::i64) &&
(DstSVT == MVT::i8 || DstSVT == MVT::i16 || DstSVT == MVT::i32)))
return SDValue();
- assert(SrcSVT.getSizeInBits() > DstSVT.getSizeInBits() && "Bad truncation");
- unsigned NumStages = Log2_32(SrcSVT.getSizeInBits() / DstSVT.getSizeInBits());
+ assert(NumSrcEltBits > NumDstEltBits && "Bad truncation");
+ unsigned NumStages = Log2_32(NumSrcEltBits / NumDstEltBits);
// Truncation from 128-bit to vXi32 can be better handled with PSHUFD.
// Truncation to sub-64-bit vXi16 can be better handled with PSHUFD/PSHUFLW.
@@ -20422,8 +20424,7 @@ static SDValue matchTruncateWithPACK(unsigned &PackOpcode, EVT DstVT,
if (Subtarget.hasAVX512() && NumStages > 1)
return SDValue();
- unsigned NumSrcEltBits = SrcVT.getScalarSizeInBits();
- unsigned NumPackedSignBits = std::min<unsigned>(DstSVT.getSizeInBits(), 16);
+ unsigned NumPackedSignBits = std::min<unsigned>(NumDstEltBits, 16);
unsigned NumPackedZeroBits = Subtarget.hasSSE41() ? NumPackedSignBits : 8;
// Truncate with PACKUS if we are truncating a vector with leading zero
@@ -20445,7 +20446,7 @@ static SDValue matchTruncateWithPACK(unsigned &PackOpcode, EVT DstVT,
// a sign splat (or AVX512 VPSRAQ support). ComputeNumSignBits struggles to
// see through BITCASTs later on and combines/simplifications can't then use
// it.
- if (DstSVT == MVT::i32 && NumSignBits != SrcSVT.getSizeInBits() &&
+ if (DstSVT == MVT::i32 && NumSignBits != NumSrcEltBits &&
!Subtarget.hasAVX512())
return SDValue();
More information about the llvm-commits
mailing list