This is an archive of the discontinued LLVM Phabricator instance.

Remove MVT:i1 xor instruction before SELECT. (Performance improvement).
ClosedPublic

Authored by aymanmus on Aug 22 2016, 12:49 AM.

Details

Summary

Fold the two following sequences:
Sequence 1 (xor with 0):
%cond1 = xor i1:%cond0 Constant<i1>0
%res = select %cond1, m, n
into:
%res = select %cond0, m, n

Sequence 2 (xor with 1):
%cond1 = xor i1:%cond0 Constant<i1>1
%res = select %cond1, m, n
into:
%res = select %cond0, n, m

Diff Detail

Repository
rL LLVM

Event Timeline

aymanmus updated this revision to Diff 68829.Aug 22 2016, 12:49 AM
aymanmus retitled this revision from to Remove MVT:i1 xor instruction before SELECT. (Performance improvement)..
aymanmus updated this object.
aymanmus added reviewers: hfinkel, MatzeB.
aymanmus added a subscriber: llvm-commits.
aymanmus added a subscriber: igorb.Aug 22 2016, 5:18 AM
hfinkel added inline comments.Aug 28 2016, 2:01 AM
lib/CodeGen/SelectionDAG/DAGCombiner.cpp
5244 ↗(On Diff #68829)

It seems like this will be generally profitable regardless of how many uses N0 has (because it will break the dependence on the xor result, plus handles the case where several selects depend on the same condition).

5245 ↗(On Diff #68829)

Add space after if.

5247 ↗(On Diff #68829)

C->isOne()

delena edited edge metadata.Aug 28 2016, 4:00 AM

Could you, please, add a test for AVX-512? MVT::i1 is legal there.

aymanmus updated this revision to Diff 69551.Aug 29 2016, 3:41 AM
aymanmus edited edge metadata.
  • Added a test for AVX512 where the improvement is significant.
  • Removed the "one use" condition for the xor instruction.
delena accepted this revision.Sep 13 2016, 1:01 AM
delena edited edge metadata.
This revision is now accepted and ready to land.Sep 13 2016, 1:01 AM
This revision was automatically updated to reflect the committed changes.