This is an archive of the discontinued LLVM Phabricator instance.

[SystemZ] Also accept ISD::USUBO in shouldFormOverflowOp()
ClosedPublic

Authored by jonpa on Feb 27 2020, 12:28 PM.

Details

Summary

Forming sub with overflow should be beneficial on SystemZ, just like for additions.

When I tried doing this for i16 the code seems to get worse, so this is only done for i32 and i64.

Added tests also for the additions since I did not find any ones at the present.

(It seems we could have done (some of) this in SystemZElimCompare if we would recognize and handle Load Address in SystemZElimCompare, but IIRC that opcode isn't used that much for additions with an immediate.)

Diff Detail

Event Timeline

jonpa created this revision.Feb 27 2020, 12:28 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 27 2020, 12:28 PM
uweigand accepted this revision.Feb 28 2020, 4:35 AM

Otherwise, LGTM. Thanks!

llvm/lib/Target/SystemZ/SystemZISelLowering.h
448

Why do you move it to the .cpp file? It still seems small enough to usefully inline ...

This revision is now accepted and ready to land.Feb 28 2020, 4:35 AM
jonpa updated this revision to Diff 247300.Feb 28 2020, 10:07 AM
jonpa marked an inline comment as done.

Sorry, I see that dag-combine-05.ll now fails. This test does not seem to really test your patch anymore (38342a5), since if (on trunk) I remove the check in getAsCarry() the test still passes. I am not sure why that is exactly, but I changed the existing test to at least give the same input to isel (by inserting the i16 intrinsic into the test case since it's now no longer generated by CodeGenPrepare).

Moved function definition to header file.

jonpa requested review of this revision.Feb 28 2020, 10:08 AM
uweigand accepted this revision.Mar 2 2020, 5:36 AM

I see. I still agree it is preferable to only generate the overflow ops for types where they will be legal.

It also makes sense to still have the test case to something valid by using an explicit overflow op.

So overall, the patch LGTM. Thanks!

This revision is now accepted and ready to land.Mar 2 2020, 5:36 AM
This revision was automatically updated to reflect the committed changes.