summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target
diff options
context:
space:
mode:
authorScott Michel <scottm@aero.org>2008-03-06 04:02:54 +0000
committerScott Michel <scottm@aero.org>2008-03-06 04:02:54 +0000
commite9b690b7f121b33cc585e7452ef6aa80a891ca1f (patch)
treeba3b789d8db3f612d54d11bd9430128e52f3df89 /llvm/lib/Target
parentea6507fe0473c595b7fd7f45ef116355c5804939 (diff)
downloadbcm5719-llvm-e9b690b7f121b33cc585e7452ef6aa80a891ca1f.tar.gz
bcm5719-llvm-e9b690b7f121b33cc585e7452ef6aa80a891ca1f.zip
Refine Cell's i64 constant generation code to cover more constants where the
upper and lower 32-bits are the same (in addition to 0 and -1 previously.) llvm-svn: 47985
Diffstat (limited to 'llvm/lib/Target')
-rw-r--r--llvm/lib/Target/CellSPU/SPUISelLowering.cpp35
1 files changed, 28 insertions, 7 deletions
diff --git a/llvm/lib/Target/CellSPU/SPUISelLowering.cpp b/llvm/lib/Target/CellSPU/SPUISelLowering.cpp
index de1fff0ccae..6d2a9f3d30b 100644
--- a/llvm/lib/Target/CellSPU/SPUISelLowering.cpp
+++ b/llvm/lib/Target/CellSPU/SPUISelLowering.cpp
@@ -1354,6 +1354,14 @@ SDOperand SPU::get_vec_u18imm(SDNode *N, SelectionDAG &DAG,
MVT::ValueType ValueType) {
if (ConstantSDNode *CN = getVecImm(N)) {
uint64_t Value = CN->getValue();
+ if (ValueType == MVT::i64) {
+ uint64_t UValue = CN->getValue();
+ uint32_t upper = uint32_t(UValue >> 32);
+ uint32_t lower = uint32_t(UValue);
+ if (upper != lower)
+ return SDOperand();
+ Value = Value >> 32;
+ }
if (Value <= 0x3ffff)
return DAG.getConstant(Value, ValueType);
}
@@ -1368,6 +1376,14 @@ SDOperand SPU::get_vec_i16imm(SDNode *N, SelectionDAG &DAG,
MVT::ValueType ValueType) {
if (ConstantSDNode *CN = getVecImm(N)) {
int64_t Value = CN->getSignExtended();
+ if (ValueType == MVT::i64) {
+ uint64_t UValue = CN->getValue();
+ uint32_t upper = uint32_t(UValue >> 32);
+ uint32_t lower = uint32_t(UValue);
+ if (upper != lower)
+ return SDOperand();
+ Value = Value >> 32;
+ }
if (Value >= -(1 << 15) && Value <= ((1 << 15) - 1)) {
return DAG.getConstant(Value, ValueType);
}
@@ -1383,6 +1399,14 @@ SDOperand SPU::get_vec_i10imm(SDNode *N, SelectionDAG &DAG,
MVT::ValueType ValueType) {
if (ConstantSDNode *CN = getVecImm(N)) {
int64_t Value = CN->getSignExtended();
+ if (ValueType == MVT::i64) {
+ uint64_t UValue = CN->getValue();
+ uint32_t upper = uint32_t(UValue >> 32);
+ uint32_t lower = uint32_t(UValue);
+ if (upper != lower)
+ return SDOperand();
+ Value = Value >> 32;
+ }
if (isS10Constant(Value))
return DAG.getConstant(Value, ValueType);
}
@@ -1626,13 +1650,10 @@ static SDOperand LowerBUILD_VECTOR(SDOperand Op, SelectionDAG &DAG) {
uint32_t upper = uint32_t(val >> 32);
uint32_t lower = uint32_t(val);
- if (val == 0) {
- SDOperand Zero = DAG.getTargetConstant(0, MVT::i64);
- return DAG.getNode(ISD::BUILD_VECTOR, VT, Zero, Zero);
- } else if (val == 0xffffffffffffffffULL) {
- // For -1, this and has a chance of matching immAllOnesV.
- SDOperand NegOne = DAG.getTargetConstant(-1, MVT::i64);
- return DAG.getNode(ISD::BUILD_VECTOR, VT, NegOne, NegOne);
+ if (upper == lower) {
+ // Magic constant that can be matched by IL, ILA, et. al.
+ SDOperand Val = DAG.getTargetConstant(val, MVT::i64);
+ return DAG.getNode(ISD::BUILD_VECTOR, VT, Val, Val);
} else {
SDOperand LO32;
SDOperand HI32;
OpenPOWER on IntegriCloud