This is an archive of the discontinued LLVM Phabricator instance.

[LegalizeTypes][ARM][AArch6][RISCV][VE][WebAssembly] Add special case for smin(X, -1) and smax(X, 0) to ExpandIntRes_MINMAX.
ClosedPublic

Authored by craig.topper on May 23 2023, 12:25 AM.

Details

Summary

We can compute a simpler expression for Lo for these cases. This
is an alternative for the test cases in D151180 that works for
more targets.

I view this as similar to some of the special cases we
have for expanding setcc operands.

Diff Detail

Event Timeline

craig.topper created this revision.May 23 2023, 12:25 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 23 2023, 12:25 AM
craig.topper requested review of this revision.May 23 2023, 12:25 AM
RKSimon accepted this revision.May 23 2023, 8:59 AM

LGTM

This revision is now accepted and ready to land.May 23 2023, 8:59 AM

The default lowering here is weird. It appears to be written to minimize the latency of the high half of the result, which is not useful in most cases.

I expect that it would be more efficient in most cases to expand to "a < b ? a : b", which can use the same condition to select both the high and low halves. Particularly on targets that have an efficient SETCCCARRY.