This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] try to reduce x86 addcarry to generic uaddo intrinsic
ClosedPublic

Authored by spatel on Jan 30 2019, 7:35 AM.

Details

Summary

If we can reduce the x86-specific intrinsic to the generic op, it allows existing simplifications and value tracking folds. AFAICT, this always results in identical x86 codegen in the non-reduced case...which should be true because we semi-generically (too aggressively IMO) convert to llvm.uadd.with.overflow in CGP, so the DAG/isel must already combine/lower this intrinsic as expected.

This isn't quite what was requested in:
https://bugs.llvm.org/show_bug.cgi?id=40486
...but I think we want to have these kinds of folds early for efficiency and to enable greater simplifications. For the case in the bug report where we have:

_addcarry_u64(0, ahi, 0, &ahi)

...this gets completely simplified away in IR.

Diff Detail

Event Timeline

spatel created this revision.Jan 30 2019, 7:35 AM

How does this affect the codegen from PR31754 ?

How does this affect the codegen from PR31754 ?

This only comes into play for the test code that uses the x86-specific C intrinsic, so it's not changing anything on the original problem examples. And for the test code (https://bugs.llvm.org/show_bug.cgi?id=31754#c3 or the expanded version in PR40486), this is only changing the test<0> instantiation so far.

RKSimon accepted this revision.Feb 1 2019, 5:45 AM

LGTM

This revision is now accepted and ready to land.Feb 1 2019, 5:45 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptFeb 1 2019, 6:14 AM