From 26cc18df43b4354a7798fb95bcdc7a92fa8be68f Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Wed, 7 Jan 2015 22:18:27 +0000 Subject: 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 --- llvm/lib/Target/R600/SIFoldOperands.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'llvm/lib') 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) { -- cgit v1.2.3