summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/R600/SIFoldOperands.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Target/R600/SIFoldOperands.cpp')
-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