summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/PowerPC
diff options
context:
space:
mode:
authorGuozhi Wei <carrot@google.com>2017-11-16 18:27:34 +0000
committerGuozhi Wei <carrot@google.com>2017-11-16 18:27:34 +0000
commit433e8d3e04280f7f4839c275fbeedb213550bed0 (patch)
tree8e6250a26136b12c44fb50c43830bb6b10f91828 /llvm/lib/Target/PowerPC
parent5e420717a1c4d9b25c645362f92dc02ccf2c5977 (diff)
downloadbcm5719-llvm-433e8d3e04280f7f4839c275fbeedb213550bed0.tar.gz
bcm5719-llvm-433e8d3e04280f7f4839c275fbeedb213550bed0.zip
[PPC] Change i32 constant in store instruction to i64
This patch changes all i32 constant in store instruction to i64 with truncation, to increase the chance that the referenced constant can be shared with other i64 constant. Differential Revision: https://reviews.llvm.org/D39352 llvm-svn: 318436
Diffstat (limited to 'llvm/lib/Target/PowerPC')
-rw-r--r--llvm/lib/Target/PowerPC/PPCISelLowering.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
index 3c3657e1f56..cab17fb2d75 100644
--- a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -12223,9 +12223,24 @@ SDValue PPCTargetLowering::PerformDAGCombine(SDNode *N,
cast<StoreSDNode>(N)->getMemOperand());
}
+ // STORE Constant:i32<0> -> STORE<trunc to i32> Constant:i64<0>
+ // So it can increase the chance of CSE constant construction.
+ EVT VT = N->getOperand(1).getValueType();
+ if (Subtarget.isPPC64() && !DCI.isBeforeLegalize() &&
+ isa<ConstantSDNode>(N->getOperand(1)) && VT == MVT::i32) {
+ SDValue Const64 = DAG.getConstant(N->getConstantOperandVal(1), dl,
+ MVT::i64);
+ // DAG.getTruncStore() can't be used here because it doesn't accept
+ // the general (base + offset) addressing mode.
+ // So we use UpdateNodeOperands and setTruncatingStore instead.
+ DAG.UpdateNodeOperands(N, N->getOperand(0), Const64, N->getOperand(2),
+ N->getOperand(3));
+ cast<StoreSDNode>(N)->setTruncatingStore(true);
+ return SDValue(N, 0);
+ }
+
// For little endian, VSX stores require generating xxswapd/lxvd2x.
// Not needed on ISA 3.0 based CPUs since we have a non-permuting store.
- EVT VT = N->getOperand(1).getValueType();
if (VT.isSimple()) {
MVT StoreVT = VT.getSimpleVT();
if (Subtarget.needsSwapsForVSXMemOps() &&
OpenPOWER on IntegriCloud