This is an archive of the discontinued LLVM Phabricator instance.

[SLP] Fix for PR32038: extra add of PHI node when it is not required.
ClosedPublic

Authored by ABataev on Feb 27 2017, 8:33 AM.

Details

Summary

If horizontal reduction tree starts from the binary operation that is
used in PHI node, but this PHI is not used in horizontal reduction, we
may end up with extra addition of this PHI node after vectorization.
Here is an example:

%phi = phi i32 [ %tmp, %end], ...
...
%tmp = add i32 %tmp1, %tmp2
end:

after vectorization we always have something like:

%phi = phi i32 [ %tmp, %end], ...
...
%red = extractelement <8 x 32> %vec.red, 0
%tmp = add i32 %red, %phi
end:

even if %phi is not used in reduction tree. Patch considers these PHI
nodes as extra arguments and considers them in the final result iff they
really used in reduction.

Event Timeline

ABataev created this revision.Feb 27 2017, 8:33 AM
mkuper edited edge metadata.Feb 28 2017, 4:36 PM

Nice, I think it's a cleaner way to treat the phis than what we had originally, regardless of the bug.
LGTM.

test/Transforms/SLPVectorizer/X86/scheduling.ll
15

You have a separate patch to get this flag back, right?

mkuper accepted this revision.Feb 28 2017, 4:36 PM
This revision is now accepted and ready to land.Feb 28 2017, 4:36 PM
ABataev marked an inline comment as done.Feb 28 2017, 11:08 PM
ABataev added inline comments.
test/Transforms/SLPVectorizer/X86/scheduling.ll
15

Yes, right

This revision was automatically updated to reflect the committed changes.
ABataev marked an inline comment as done.