summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorTom Stellard <thomas.stellard@amd.com>2015-01-07 22:18:27 +0000
committerTom Stellard <thomas.stellard@amd.com>2015-01-07 22:18:27 +0000
commit26cc18df43b4354a7798fb95bcdc7a92fa8be68f (patch)
tree3b603f87e518b2b0a6ad80f6c6ae2a634a29eb7e /llvm/lib
parentc43add077beb6d309815765b13cd235e803d1560 (diff)
downloadbcm5719-llvm-26cc18df43b4354a7798fb95bcdc7a92fa8be68f.tar.gz
bcm5719-llvm-26cc18df43b4354a7798fb95bcdc7a92fa8be68f.zip
R600/SI: Only fold immediates that have one use
Folding the same immediate into multiple instruction will increase program size, which can hurt performance. llvm-svn: 225405
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Target/R600/SIFoldOperands.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/llvm/lib/Target/R600/SIFoldOperands.cpp b/llvm/lib/Target/R600/SIFoldOperands.cpp
index ddb285213d2..545905ba64e 100644
--- a/llvm/lib/Target/R600/SIFoldOperands.cpp
+++ b/llvm/lib/Target/R600/SIFoldOperands.cpp
@@ -138,6 +138,14 @@ bool SIFoldOperands::runOnMachineFunction(MachineFunction &MF) {
continue;
MachineOperand &OpToFold = MI.getOperand(1);
+ bool FoldingImm = OpToFold.isImm() || OpToFold.isFPImm();
+
+ // Folding immediates with more than one use will increase program side.
+ // FIXME: This will also reduce register usage, which may be better
+ // in some cases. A better heuristic is needed.
+ if (FoldingImm && !TII->isInlineConstant(OpToFold) &&
+ !MRI.hasOneUse(MI.getOperand(0).getReg()))
+ continue;
// FIXME: Fold operands with subregs.
if (OpToFold.isReg() &&
@@ -158,7 +166,6 @@ bool SIFoldOperands::runOnMachineFunction(MachineFunction &MF) {
continue;
}
- bool FoldingImm = OpToFold.isImm() || OpToFold.isFPImm();
APInt Imm;
if (FoldingImm) {
OpenPOWER on IntegriCloud