[TwoAddressInstructionPass] Replace subregister uses when processing tied operands
commitffc5ec8c8122b984871c59516426cdd8ad18e7ea
authorBjorn Pettersson <bjorn.a.pettersson@ericsson.com>
Mon, 15 Oct 2018 08:36:03 +0000 (15 08:36 +0000)
committerBjorn Pettersson <bjorn.a.pettersson@ericsson.com>
Mon, 15 Oct 2018 08:36:03 +0000 (15 08:36 +0000)
treeb20aec1ae23b389e4210580f7e0cd1a400676b8e
parent15ca92098aa137c257b7dfea86c7b4daa8eaf1af
[TwoAddressInstructionPass] Replace subregister uses when processing tied operands

Summary:
TwoAddressInstruction pass typically rewrites
  %1:short = foo %0.sub_lo:long
as
  %1:short = COPY %0.sub_lo:long
  %1:short = foo %1:short
when having tied operands.

If there are extra un-tied operands that uses the same reg and
subreg, such as the second and third inputs to fie here:
  %1:short = fie %0.sub_lo:long, %0.sub_hi:long, %0.sub_lo:long
then there was a bug which replaced the register %0 also for
the un-tied operand, but without changing the subregister indices.
So we used to get:
  %1:short = COPY %0.sub_lo:long
  %1:short = fie %1, %1.sub_hi:short, %1.sub_lo:short
With this fix we instead get:
  %1:short = COPY %0.sub_lo:long
  %1:short = fie %1, %0.sub_hi:long, %1

Reviewers: arsenm, JesperAntonsson, kparzysz, MatzeB

Reviewed By: MatzeB

Subscribers: bjope, kparzysz, wdng, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344492 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/TwoAddressInstructionPass.cpp
test/CodeGen/Hexagon/two-addr-tied-subregs.mir [new file with mode: 0644]