summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorMarek Olsak <marek.olsak@amd.com>2016-01-13 11:44:29 +0000
committerMarek Olsak <marek.olsak@amd.com>2016-01-13 11:44:29 +0000
commit926c56f50c35e52e4acf6841b2fd9419f355c736 (patch)
tree8dcebdff5f0a2ecc42daabfbdade3fff441a886d /llvm/lib
parent1ce2c9973fa78e53be887f0a53f6939d2d1f3bf9 (diff)
downloadbcm5719-llvm-926c56f50c35e52e4acf6841b2fd9419f355c736.tar.gz
bcm5719-llvm-926c56f50c35e52e4acf6841b2fd9419f355c736.zip
AMDGPU/SI: Fix a bug in SIFoldOperands
Summary: ret.ll will contain a test for this Reviewers: tstellarAMD, arsenm Subscribers: arsenm Differential Revision: http://reviews.llvm.org/D16029 llvm-svn: 257590
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Target/AMDGPU/SIFoldOperands.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp b/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp
index ccbf7c80f2a..6230d1e28b7 100644
--- a/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp
+++ b/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp
@@ -338,6 +338,17 @@ bool SIFoldOperands::runOnMachineFunction(MachineFunction &MF) {
!TargetRegisterInfo::isVirtualRegister(OpToFold.getReg()))
continue;
+ // Prevent folding operands backwards in the function. For example,
+ // the COPY opcode must not be replaced by 1 in this example:
+ //
+ // %vreg3<def> = COPY %VGPR0; VGPR_32:%vreg3
+ // ...
+ // %VGPR0<def> = V_MOV_B32_e32 1, %EXEC<imp-use>
+ MachineOperand &Dst = MI.getOperand(0);
+ if (Dst.isReg() &&
+ !TargetRegisterInfo::isVirtualRegister(Dst.getReg()))
+ continue;
+
// We need mutate the operands of new mov instructions to add implicit
// uses of EXEC, but adding them invalidates the use_iterator, so defer
// this.
OpenPOWER on IntegriCloud