This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] enhance freelyNegateValue() by handling xor
ClosedPublic

Authored by spatel on Apr 1 2020, 10:23 AM.

Details

Summary

Negation is equivalent to bitwise-not + 1, so try to convert more subtracts into adds using this relationship:
0 - (A ^ C) => ((A ^ C) ^ -1) + 1 => A ^ ~C + 1

I doubt this will recover the regression noted in rGf2fbdf76d8d0, but seems like we're going to need to improve here and/or revive D68408?

Alive2 proofs:
http://volta.cs.utah.edu:8080/z/Re5tMU
http://volta.cs.utah.edu:8080/z/An-uns

Diff Detail