summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/X86/X86ShuffleDecodeConstantPool.cpp
diff options
context:
space:
mode:
authorSimon Pilgrim <llvm-dev@redking.me.uk>2017-02-24 17:46:18 +0000
committerSimon Pilgrim <llvm-dev@redking.me.uk>2017-02-24 17:46:18 +0000
commitbd9fb2ae959dc2bc0a2a6a309b56ea239d41797e (patch)
treef6b76d75fb74cca216bc2f37094c6d97c0ba4d13 /llvm/lib/Target/X86/X86ShuffleDecodeConstantPool.cpp
parent24a1bedf765fd2dab8384073c9ac930563fa0110 (diff)
downloadbcm5719-llvm-bd9fb2ae959dc2bc0a2a6a309b56ea239d41797e.tar.gz
bcm5719-llvm-bd9fb2ae959dc2bc0a2a6a309b56ea239d41797e.zip
[APInt] Add APInt::extractBits() method to extract APInt subrange
The current pattern for extract bits in range is typically: Mask.lshr(BitOffset).trunc(SubSizeInBits); Which can be particularly slow for large APInts (MaskSizeInBits > 64) as they require the allocation of memory for the temporary variable. This is another of the compile time issues identified in PR32037 (see also D30265). This patch adds the APInt::extractBits() helper method which avoids the temporary memory allocation. Differential Revision: https://reviews.llvm.org/D30336 llvm-svn: 296141
Diffstat (limited to 'llvm/lib/Target/X86/X86ShuffleDecodeConstantPool.cpp')
-rw-r--r--llvm/lib/Target/X86/X86ShuffleDecodeConstantPool.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/llvm/lib/Target/X86/X86ShuffleDecodeConstantPool.cpp b/llvm/lib/Target/X86/X86ShuffleDecodeConstantPool.cpp
index 41ad0971461..c24b74f7480 100644
--- a/llvm/lib/Target/X86/X86ShuffleDecodeConstantPool.cpp
+++ b/llvm/lib/Target/X86/X86ShuffleDecodeConstantPool.cpp
@@ -77,8 +77,8 @@ static bool extractConstantMask(const Constant *C, unsigned MaskEltSizeInBits,
RawMask.resize(NumMaskElts, 0);
for (unsigned i = 0; i != NumMaskElts; ++i) {
- APInt EltUndef = UndefBits.lshr(i * MaskEltSizeInBits);
- EltUndef = EltUndef.zextOrTrunc(MaskEltSizeInBits);
+ unsigned BitOffset = i * MaskEltSizeInBits;
+ APInt EltUndef = UndefBits.extractBits(MaskEltSizeInBits, BitOffset);
// Only treat the element as UNDEF if all bits are UNDEF, otherwise
// treat it as zero.
@@ -88,8 +88,7 @@ static bool extractConstantMask(const Constant *C, unsigned MaskEltSizeInBits,
continue;
}
- APInt EltBits = MaskBits.lshr(i * MaskEltSizeInBits);
- EltBits = EltBits.zextOrTrunc(MaskEltSizeInBits);
+ APInt EltBits = MaskBits.extractBits(MaskEltSizeInBits, BitOffset);
RawMask[i] = EltBits.getZExtValue();
}
OpenPOWER on IntegriCloud