This is an archive of the discontinued LLVM Phabricator instance.

[DAGCombiner][X86] Fold (sub (subcarry X, 0, Carry), Y) -> (subcarry X, Y, Carry)
ClosedPublic

Authored by craig.topper on Sep 7 2022, 10:09 PM.

Diff Detail

Event Timeline

craig.topper created this revision.Sep 7 2022, 10:09 PM
craig.topper requested review of this revision.Sep 7 2022, 10:09 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 7 2022, 10:09 PM

Is the transform still profitable if the subcarry has another use? (not sure how to write a test for that)

In IR, it looks like we'd reduce the equivalent of "subcarry X, 0, Carry" to "usubo X, Carry". Are those the same semantics for this node? And would that simpler transform make sense in SDAG too?

Is the transform still profitable if the subcarry has another use? (not sure how to write a test for that)

I copied this code from visitAddLikeCommutative and changed ADDCARRY to SUBCARRY. So any one uses check is also missing there.

In IR, it looks like we'd reduce the equivalent of "subcarry X, 0, Carry" to "usubo X, Carry". Are those the same semantics for this node? And would that simpler transform make sense in SDAG too?

Carry here has bool type so I don't think we can fold it to "usubo X, Carry" without an extend.

spatel accepted this revision.Sep 8 2022, 8:59 AM

Is the transform still profitable if the subcarry has another use? (not sure how to write a test for that)

I copied this code from visitAddLikeCommutative and changed ADDCARRY to SUBCARRY. So any one uses check is also missing there.

I see...that goes back to D32738. I'd put the one-use limit on both as a conservative first step unless there's a test showing this way is better.

LGTM, but let's see if @deadalnix has any suggestions.

This revision is now accepted and ready to land.Sep 8 2022, 8:59 AM
This revision was landed with ongoing or failed builds.Sep 8 2022, 11:24 PM
This revision was automatically updated to reflect the committed changes.