This is an archive of the discontinued LLVM Phabricator instance.

[DAG] foldSubToUSubSat - fold sub(a,trunc(umin(zext(a),b))) -> usubsat(a,trunc(umin(b,SatLimit)))
ClosedPublic

Authored by RKSimon on Feb 15 2021, 4:33 AM.

Details

Summary

This moves the last custom x86 USUBSAT fold to generic DAGCombine.

Completes PR40111

Diff Detail

Event Timeline

RKSimon created this revision.Feb 15 2021, 4:33 AM
RKSimon requested review of this revision.Feb 15 2021, 4:33 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 15 2021, 4:33 AM
pengfei added inline comments.Feb 15 2021, 5:33 AM
llvm/test/CodeGen/X86/psubus.ll
2496–2497

We can use SSE2-SSE3 now.

RKSimon updated this revision to Diff 323733.Feb 15 2021, 6:19 AM

Merge SSE2 + SSE3 codegen where possible

craig.topper added inline comments.Feb 18 2021, 10:54 AM
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
3192

What is 'c' here? It doesn't appear in the sub(a,trunc(umin(zext(a),b))) pattern

craig.topper added inline comments.Feb 18 2021, 11:00 AM
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
3155–3156

Is this always a truncate and never a ZExt?

3192

Or is 'c' a constant which I think we usually write as capital C?

RKSimon added inline comments.Feb 18 2021, 12:19 PM
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
3155–3156

Its always a truncate - its me being lazy (and I think an older implementation used to overflow 80col line). I'll change it as a NFC.

3192

Yes - its a constant - do you think "C" or "SatLimit" would be better?

RKSimon added inline comments.Feb 18 2021, 1:32 PM
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
3155–3156
craig.topper added inline comments.Feb 18 2021, 11:28 PM
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
3192

Let's go with SatLimit.

RKSimon updated this revision to Diff 324936.Feb 19 2021, 3:25 AM

Explicit umin SatLimit constant in the comment

This revision is now accepted and ready to land.Feb 19 2021, 10:06 AM
RKSimon retitled this revision from [DAG] foldSubToUSubSat - fold sub(a,trunc(umin(zext(a),b))) -> usubsat(a,trunc(umin(b,c))) to [DAG] foldSubToUSubSat - fold sub(a,trunc(umin(zext(a),b))) -> usubsat(a,trunc(umin(b,SatLimit))).Feb 19 2021, 10:39 AM
This revision was landed with ongoing or failed builds.Feb 20 2021, 4:02 AM
This revision was automatically updated to reflect the committed changes.