This is an archive of the discontinued LLVM Phabricator instance.

Codegen: [PPC] Fix PPCVSXFMAMutate to handle duplicates.
ClosedPublic

Authored by iteratee on Jan 27 2016, 5:40 PM.

Details

Summary

The purpose of PPCVSXFMAMutate is to elide copies by changing FMA forms
on PPC.

%vreg6<def> = COPY %vreg96
%vreg6<def,tied1> = XSMADDASP %vreg6<tied0>, %vreg5<kill>, %vreg7
;v6 = v6 + v5 * v7

is replaced by

%vreg5<def,tied1> = XSMADDMSP %vreg5<tied0>, %vreg7, %vreg96
;v5 = v5 * v7 + v96

This was broken in the case where the target register was also used as a
multiplicand. Fix this case by checking for it and replacing both uses
with the copied register.

%vreg6<def> = COPY %vreg96
%vreg6<def,tied1> = XSMADDASP %vreg6<tied0>, %vreg5<kill>, %vreg6
;v6 = v6 + v5 * v6

is replaced by

%vreg5<def,tied1> = XSMADDMSP %vreg5<tied0>, %vreg96, %vreg96
;v5 = v5 * v96 + v96

Diff Detail

Event Timeline

iteratee updated this revision to Diff 46204.Jan 27 2016, 5:40 PM
iteratee retitled this revision from to Codegen: [PPC] Fix PPCVSXFMAMutate to handle duplicates..
iteratee updated this object.
iteratee added reviewers: hfinkel, echristo, timshen.
iteratee set the repository for this revision to rL LLVM.
iteratee added a subscriber: llvm-commits.
echristo edited edge metadata.Jan 28 2016, 3:24 PM

Seems reasonable to me, might want to wait for Kit or Hal to speak up.

-eric

hfinkel accepted this revision.Feb 2 2016, 1:47 PM
hfinkel edited edge metadata.

LGTM

lib/Target/PowerPC/PPCVSXFMAMutate.cpp
255

addendSrc -> AddendSrc (in comment, either make capitalization match variable name, or write prose.)

This revision is now accepted and ready to land.Feb 2 2016, 1:47 PM
iteratee closed this revision.Feb 3 2016, 2:52 PM