This is an archive of the discontinued LLVM Phabricator instance.

[CGP] eliminate a sub instruction in memcmp expansion
ClosedPublic

Authored by spatel on Jun 20 2017, 12:41 PM.

Details

Summary

As noted in D34071, there are some IR optimization opportunities that could be handled by normal IR passes if this expansion wasn't happening so late in CGP.

Regardless of that, it seems wasteful to knowingly produce suboptimal IR here, so I'm proposing this change:
%s = sub i32 %x, %y
%r = icmp ne %s, 0

=>

%r = icmp ne %x, %y

Changing the predicate to 'eq' mimics what InstCombine would do, so that's just an efficiency improvement if we decide this expansion should happen sooner.

The fact that the PowerPC backend doesn't eliminate the 'subf.' might be something for PPC folks to investigate separately.

Diff Detail

Event Timeline

spatel created this revision.Jun 20 2017, 12:41 PM
This revision is now accepted and ready to land.Jun 27 2017, 2:27 PM
This revision was automatically updated to reflect the committed changes.