AMDGPU: Fix Two Address problems with v_movreld
authorNicolai Haehnle <nhaehnle@gmail.com>
Mon, 24 Oct 2016 14:56:02 +0000 (14:56 +0000)
committerNicolai Haehnle <nhaehnle@gmail.com>
Mon, 24 Oct 2016 14:56:02 +0000 (14:56 +0000)
commita785209bc2fb8b779d1aab3498e9641943306b17
tree9ddf73deae332ea179a2291542337c1c44fc3239
parentb38d3411064bb59641714fde981564cf51217308
AMDGPU: Fix Two Address problems with v_movreld

Summary:
The v_movreld machine instruction is used with three operands that are
in a sense tied to each other (the explicit VGPR_32 def and the implicit
VGPR_NN def and use). There is no way to express that using the currently
available operand bits, and indeed there are cases where the Two Address
instructions pass does the wrong thing.

This patch introduces a new set of pseudo instructions that are identical
in intended semantics as v_movreld, but they only have two tied operands.

Having to add a new set of pseudo instructions is admittedly annoying, but
it's a fairly straightforward and solid approach. The only alternative I
see is to try to teach the Two Address instructions pass about Three Address
instructions, and I'm afraid that's trickier and is going to end up more
fragile.

Note that v_movrels does not suffer from this problem, and so this patch
does not touch it.

This fixes several GL45-CTS.shaders.indexing.* tests.

Reviewers: tstellarAMD, arsenm

Subscribers: kzhuravl, wdng, yaxunl, llvm-commits, tony-tye

Differential Revision: https://reviews.llvm.org/D25633

llvm-svn: 284980
llvm/lib/Target/AMDGPU/SIISelLowering.cpp
llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
llvm/lib/Target/AMDGPU/VOP1Instructions.td
llvm/test/CodeGen/AMDGPU/movreld-bug.ll [new file with mode: 0644]