This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] enhance freelyNegateValue() by handling 'not'
ClosedPublic

Authored by spatel on Apr 4 2020, 6:59 AM.

Details

Summary

This patch extends D77230. If we have a 'not' instruction inside a negated expression, we can ignore extra uses of that op because the negation has a one-to-one replacement: negate becomes increment.

Alive2 examples of the test cases:
http://volta.cs.utah.edu:8080/z/T5-u9P
http://volta.cs.utah.edu:8080/z/eT89L6

Diff Detail

Event Timeline

spatel created this revision.Apr 4 2020, 6:59 AM
spatel added a comment.Apr 4 2020, 7:05 AM

Note that we don't see test diffs for simpler cases because we already handle this related pattern:

// C - ~X == X + (1+C)
if (match(Op1, m_Not(m_Value(X))))
  return BinaryOperator::CreateAdd(X, AddOne(C));
lebedev.ri accepted this revision.Apr 4 2020, 7:15 AM

LG
I'll attempt to resurrect Negator patch..

This revision is now accepted and ready to land.Apr 4 2020, 7:15 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptApr 5 2020, 6:23 AM