diff options
author | Simon Pilgrim <llvm-dev@redking.me.uk> | 2017-03-10 13:44:32 +0000 |
---|---|---|
committer | Simon Pilgrim <llvm-dev@redking.me.uk> | 2017-03-10 13:44:32 +0000 |
commit | b02667c469493e8f1eee4601d175942c9e80c73d (patch) | |
tree | ca9f54e6c64afb485db66deae194e50ae5dc57bb /llvm/lib/Target/X86/X86ISelLowering.cpp | |
parent | 7090d145e8eb0164e5862321e76ecfc1736dd741 (diff) | |
download | bcm5719-llvm-b02667c469493e8f1eee4601d175942c9e80c73d.tar.gz bcm5719-llvm-b02667c469493e8f1eee4601d175942c9e80c73d.zip |
[APInt] Add APInt::insertBits() method to insert an APInt into a larger APInt
We currently have to insert bits via a temporary variable of the same size as the target with various shift/mask stages, resulting in further temporary variables, all of which require the allocation of memory for large APInts (MaskSizeInBits > 64).
This is another of the compile time issues identified in PR32037 (see also D30265).
This patch adds the APInt::insertBits() helper method which avoids the temporary memory allocation and masks/inserts the raw bits directly into the target.
Differential Revision: https://reviews.llvm.org/D30780
llvm-svn: 297458
Diffstat (limited to 'llvm/lib/Target/X86/X86ISelLowering.cpp')
-rw-r--r-- | llvm/lib/Target/X86/X86ISelLowering.cpp | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp index 533ee7c6a43..872f3d5d12a 100644 --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -5318,12 +5318,11 @@ static bool getTargetConstantBitsFromNode(SDValue Op, unsigned EltSizeInBits, return true; } if (auto *CInt = dyn_cast<ConstantInt>(Cst)) { - Mask |= CInt->getValue().zextOrTrunc(SizeInBits).shl(BitOffset); + Mask.insertBits(CInt->getValue(), BitOffset); return true; } if (auto *CFP = dyn_cast<ConstantFP>(Cst)) { - APInt CstBits = CFP->getValueAPF().bitcastToAPInt(); - Mask |= CstBits.zextOrTrunc(SizeInBits).shl(BitOffset); + Mask.insertBits(CFP->getValueAPF().bitcastToAPInt(), BitOffset); return true; } return false; @@ -5340,7 +5339,7 @@ static bool getTargetConstantBitsFromNode(SDValue Op, unsigned EltSizeInBits, } auto *Cst = cast<ConstantSDNode>(Src); APInt Bits = Cst->getAPIntValue().zextOrTrunc(SrcEltSizeInBits); - MaskBits |= Bits.zext(SizeInBits).shl(BitOffset); + MaskBits.insertBits(Bits, BitOffset); } return SplitBitData(); } |