[CodeGen] Enhance machine PHIs optimization
authorDinar Temirbulatov <dtemirbulatov@gmail.com>
Sat, 15 Dec 2018 14:37:01 +0000 (14:37 +0000)
committerDinar Temirbulatov <dtemirbulatov@gmail.com>
Sat, 15 Dec 2018 14:37:01 +0000 (14:37 +0000)
commit8c8724dd0d12b06178797b825177583c33002d96
tree7a9b67d4726c69a2ac4a5a1c2f19a129a6bfa9d1
parentbfbe510d4f127f916318c9b3712514cd5a031749
[CodeGen] Enhance machine PHIs optimization

Summary:
Make machine PHIs optimization to work for single value register taken from
several different copies. This is the first step to fix PR38917. This change
allows to get rid of redundant PHIs (see opt_phis2.mir test) to make
the subsequent optimizations (like CSE) possible and simpler.

For instance, before this patch the code like this:

%b = COPY %z
...
%a = PHI %bb1, %a; %bb2, %b
could be optimized to:

%a = %b
but the code like this:

%c = COPY %z
...
%b = COPY %z
...
%a = PHI %bb1, %a; %bb2, %b; %bb3, %c
would remain unchanged.
With this patch the latter case will be optimized:

%a = %z```.

Committed on behalf of: Anton Afanasyev anton.a.afanasyev@gmail.com

Reviewers: RKSimon, MatzeB

Subscribers: llvm-commits

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

llvm-svn: 349271
llvm/lib/CodeGen/OptimizePHIs.cpp
llvm/test/CodeGen/X86/madd.ll
llvm/test/CodeGen/X86/opt_phis2.mir [new file with mode: 0644]
llvm/test/CodeGen/X86/sad.ll