This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] Fold (mul(abs(x),abs(x))) -> (mul(x,x)) (PR39476)
ClosedPublic

Authored by RKSimon on May 4 2020, 3:14 AM.

Details

Summary

This patch adds support for discarding integer absolutes (abs + nabs variants) from self-multiplications.

ABS Alive2: http://volta.cs.utah.edu:8080/z/rwcc8W
NABS Alive: http://volta.cs.utah.edu:8080/z/jZXUwQ

This is an InstCombine version of D79304 - I'm not sure yet if we'll need D79304 or not after this.

Diff Detail

Event Timeline

RKSimon created this revision.May 4 2020, 3:14 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 4 2020, 3:14 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
lebedev.ri accepted this revision.May 4 2020, 4:20 AM

LG, thank you

This revision is now accepted and ready to land.May 4 2020, 4:20 AM
xbolva00 accepted this revision.May 4 2020, 4:51 AM
This revision was automatically updated to reflect the committed changes.

SPF_ABS doesn't check the nsw flag on the negation subtract, but all the tests and the Alive proofs have nsw. It look like its still valid without the nsw so just wanted to mention it.