This is an archive of the discontinued LLVM Phabricator instance.

[IR] Add integer min/max/abs intrinsics
ClosedPublic

Authored by nikic on Jul 19 2020, 8:15 AM.

Details

Summary

This adds the umin, umax, smin, smax and abs intrinsics specified in D81829. The ISD opcodes and all the legalization and lowering already exist, so this just wires them up to the intrinsic in the SDAG builder and adds rudimentary tests.

Diff Detail

Event Timeline

nikic created this revision.Jul 19 2020, 8:15 AM

Maybe add langref docs entries as well?

I was mainly waiting until after the branch to look into these, guess i won't.

nikic added a comment.Jul 19 2020, 2:27 PM

@RKSimon I've linked the corresponding LangRef patch as a parent now.

@lebedev.ri Feel free to take over if you prefer :) I'd like the intrinsics landed ASAP so everyone can start working on the long list of necessary pass integrations in parallel. It wasn't obvious to me that the last month of inactivity was due to branching and not just a lack of time.

arsenm added a subscriber: arsenm.Jul 19 2020, 6:30 PM

Should also handle GlobalISel. The effort part for min/max should be done already, but I think abs is missing

nikic updated this revision to Diff 279326.Jul 20 2020, 12:25 PM

Add globalisel IR translation support.

spatel accepted this revision.Jul 22 2020, 6:02 AM

LGTM. I haven't looked at GlobalISel much, so may want to get a 2nd opinion on that part.

This revision is now accepted and ready to land.Jul 22 2020, 6:02 AM
arsenm added inline comments.Jul 22 2020, 6:04 AM
llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
1495–1505 ↗(On Diff #279326)

The IRTranslator should not expand operations. This should add a G_ABS opcode and move this to LegalizerHelper

nikic updated this revision to Diff 279910.Jul 22 2020, 12:22 PM

Remove GlobalISel support. It can be implemented in a separate revision.

Remove GlobalISel support. It can be implemented in a separate revision.

Only the G_ABS handling should be separate

nikic updated this revision to Diff 279929.Jul 22 2020, 1:16 PM

Restore GlobalISel support for umin/umax/smin/smax, only leave out abs.

arsenm accepted this revision.Jul 22 2020, 1:19 PM
This revision was automatically updated to reflect the committed changes.