This is an archive of the discontinued LLVM Phabricator instance.

[DAGCombiner] (add (umax X, C), -C) --> (usubsat X, C) (PR40111)
ClosedPublic

Authored by RKSimon on Feb 5 2019, 7:30 AM.

Details

Summary

Move the (add (umax X, C), -C) --> (usubsat X, C) X86 combine into generic DAGCombiner

First of a number of saturated arithmetic folds that can be moved out of X86-specific code for PR40111.

Diff Detail

Repository
rL LLVM

Event Timeline

RKSimon created this revision.Feb 5 2019, 7:30 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 5 2019, 7:30 AM
nikic added inline comments.Feb 5 2019, 11:41 AM
lib/CodeGen/SelectionDAG/DAGCombiner.cpp
2164 ↗(On Diff #185307)

I'm not familiar with the nuances of the legality checking here, but wondering if using the hasOperation(ISD::USUBSAT, VT) helper would make more sense? If usubsat is not legal or custom, then the created usubsat is going to be expanded back into umax+add during legalization again anyway.

RKSimon updated this revision to Diff 185521.Feb 6 2019, 3:37 AM

Use hasOperation

nikic accepted this revision.Feb 6 2019, 11:54 AM

LGTM

This revision is now accepted and ready to land.Feb 6 2019, 11:54 AM
This revision was automatically updated to reflect the committed changes.