This is an archive of the discontinued LLVM Phabricator instance.

[X86] Add custom type legalization for i64 saddo/ssubo on 32-bit targets. Same for i128 on 64-bit targets.
AbandonedPublic

Authored by craig.topper on Oct 11 2020, 12:06 AM.

Details

Summary

The default type legalization generates multiple compares to check
the overflow condition. But on X86 we can just emit an add/sub with
flags output followed by a adc/sbb and check the overflow flag.

I don't think the bug mentioned in the comment I removed applies
anymore. And if it is an issue I don't see why it wouldn't be
an issue with the expanded code we already get for UADDO/USUBO.

Diff Detail

Event Timeline

craig.topper created this revision.Oct 11 2020, 12:06 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 11 2020, 12:06 AM
craig.topper requested review of this revision.Oct 11 2020, 12:06 AM
RKSimon added inline comments.Oct 11 2020, 6:10 AM
llvm/test/CodeGen/X86/known-bits.ll
149

Any idea what happened here?

craig.topper added inline comments.Oct 11 2020, 11:04 AM
llvm/test/CodeGen/X86/known-bits.ll
149

We don't see the zeroes until after type legalization and we don't have constant folding for X86ISD::ADD. Probably because we'd need to know which flags are being used.

I suppose we could combine it by looking back from the ADC?

Would it make sense to add target-independent SADDO_CARRY/SSUBO_CARRY? We already have SETCCCARRY.

craig.topper abandoned this revision.Oct 13 2020, 12:51 AM

Handled by D89222.