summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorYaxun Liu <Yaxun.Liu@amd.com>2017-11-23 03:08:51 +0000
committerYaxun Liu <Yaxun.Liu@amd.com>2017-11-23 03:08:51 +0000
commit6aaae46f93720801a83c0738491d4cf5f1968f2b (patch)
treef468b8de4a270979c3613481848b1f4a53807920 /llvm/lib
parentb6ad844e136e5c5ad80db276f884e20cc0bfc0ee (diff)
downloadbcm5719-llvm-6aaae46f93720801a83c0738491d4cf5f1968f2b.tar.gz
bcm5719-llvm-6aaae46f93720801a83c0738491d4cf5f1968f2b.zip
[NFC] CodeGen: Handle shift amount type in DAGTypeLegalizer::SplitInteger
This patch reverts change to X86TargetLowering::getScalarShiftAmountTy in rL318727 and move the logic to DAGTypeLegalizer::SplitInteger. The reason is that getScalarShiftAmountTy returns a shift amount type that is suitable for common use cases in CodeGen. DAGTypeLegalizer::SplitInteger is a rare situation which requires a shift amount type larger than what getScalarShiftAmountTy. In this case, it is more reasonable to do special handling of shift amount type in DAGTypeLegalizer::SplitInteger only. If similar situations arises the logic may be moved to a separate function. Differential Revision: https://reviews.llvm.org/D40320 llvm-svn: 318890
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp13
-rw-r--r--llvm/lib/Target/X86/X86ISelLowering.h9
2 files changed, 9 insertions, 13 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
index 699081e2a5c..88c5dddfec4 100644
--- a/llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
@@ -1172,11 +1172,14 @@ void DAGTypeLegalizer::SplitInteger(SDValue Op,
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);
}
diff --git a/llvm/lib/Target/X86/X86ISelLowering.h b/llvm/lib/Target/X86/X86ISelLowering.h
index fc8519bb973..3b1cc2e55af 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.h
+++ b/llvm/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 {
@@ -676,14 +675,8 @@ namespace llvm {
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 *
OpenPOWER on IntegriCloud