This is an archive of the discontinued LLVM Phabricator instance.

[SelectionDAG] ComputeNumSignBits - add support for SMIN+SMAX clamp patterns
ClosedPublic

Authored by RKSimon on Feb 15 2018, 9:00 AM.

Details

Summary

If we have a clamp pattern, SMIN(SMAX(X, LO),HI) or SMAX(SMIN(X, HI),LO) then we can deduce that the number of signbits will be at least the minimum of the LO and HI constants.

I haven't bothered with the UMIN/UMAX equivalent as (1) we don't have any current use cases and (2) I wonder if we'd be better off immediately falling back for ComputeKnownBits for UMIN/UMAX which already has optimization patterns useful for unsigned cases.

Diff Detail

Repository
rL LLVM

Event Timeline

RKSimon created this revision.Feb 15 2018, 9:00 AM
craig.topper added inline comments.Feb 15 2018, 10:21 PM
lib/CodeGen/SelectionDAG/SelectionDAG.cpp
3212 ↗(On Diff #134441)

Opcode can't ever be UMAX here right? Was this supposed to SMIN?

RKSimon updated this revision to Diff 134812.Feb 17 2018, 11:32 AM

Rebased, and dropped remnants of UMIN/UMAX support.

This revision is now accepted and ready to land.Feb 17 2018, 12:39 PM
This revision was automatically updated to reflect the committed changes.