[PATCH] D40320: [NFC] CodeGen: Handle shift amount type in DAGTypeLegalizer::SplitInteger
Yaxun Liu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 21 19:30:33 PST 2017
yaxunl updated this revision to Diff 123876.
yaxunl added a comment.
Revised by Eli's comments.
https://reviews.llvm.org/D40320
Files:
lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
lib/Target/X86/X86ISelLowering.h
Index: lib/Target/X86/X86ISelLowering.h
===================================================================
--- lib/Target/X86/X86ISelLowering.h
+++ lib/Target/X86/X86ISelLowering.h
@@ -18,7 +18,6 @@
#include "llvm/CodeGen/CallingConvLower.h"
#include "llvm/CodeGen/SelectionDAG.h"
#include "llvm/CodeGen/TargetLowering.h"
-#include "llvm/Support/MathExtras.h"
#include "llvm/Target/TargetOptions.h"
namespace llvm {
@@ -665,14 +664,8 @@
void markLibCallAttributes(MachineFunction *MF, unsigned CC,
ArgListTy &Args) const override;
- // For i512, DAGTypeLegalizer::SplitInteger needs a shift amount 256,
- // which cannot be held by i8, therefore use i16 instead. In all the
- // other situations i8 is sufficient.
MVT getScalarShiftAmountTy(const DataLayout &, EVT VT) const override {
- MVT T = VT.getSizeInBits() >= 512 ? MVT::i16 : MVT::i8;
- assert((VT.getSizeInBits() + 1) / 2 < (1U << T.getSizeInBits()) &&
- "Scalar shift amount type too small");
- return T;
+ return MVT::i8;
}
const MCExpr *
Index: lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
===================================================================
--- lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
+++ lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
@@ -1172,11 +1172,14 @@
assert(LoVT.getSizeInBits() + HiVT.getSizeInBits() ==
Op.getValueSizeInBits() && "Invalid integer splitting!");
Lo = DAG.getNode(ISD::TRUNCATE, dl, LoVT, Op);
- Hi =
- DAG.getNode(ISD::SRL, dl, Op.getValueType(), Op,
- DAG.getConstant(LoVT.getSizeInBits(), dl,
- TLI.getScalarShiftAmountTy(
- DAG.getDataLayout(), Op.getValueType())));
+ unsigned ReqShiftAmountInBits =
+ Log2_32_Ceil(Op.getValueType().getSizeInBits());
+ MVT ShiftAmountTy =
+ TLI.getScalarShiftAmountTy(DAG.getDataLayout(), Op.getValueType());
+ if (ReqShiftAmountInBits > ShiftAmountTy.getSizeInBits())
+ ShiftAmountTy = MVT::getIntegerVT(NextPowerOf2(ReqShiftAmountInBits));
+ Hi = DAG.getNode(ISD::SRL, dl, Op.getValueType(), Op,
+ DAG.getConstant(LoVT.getSizeInBits(), dl, ShiftAmountTy));
Hi = DAG.getNode(ISD::TRUNCATE, dl, HiVT, Hi);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40320.123876.patch
Type: text/x-patch
Size: 2304 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171122/9daf2009/attachment.bin>
More information about the llvm-commits
mailing list