Page MenuHomePhabricator

[SelectionDAG] Improve knownbits handling of UMIN/UMAX (PR31293)

Authored by RKSimon on Jan 18 2017, 4:06 AM.



This patch improves the knownbits logic for unsigned integer min/max opcodes.

For UMIN we know that the result will have the maximum of the inputs' known leading zero bits in the result, similarly for UMAX the maximum of the inputs' leading one bits.

This is particularly useful for simplifying clamping patterns,. e.g. as SSE doesn't have a uitofp instruction we want to use sitofp instead where possible and for that we need to confirm that the top bit is not set.

Diff Detail


Event Timeline

RKSimon created this revision.Jan 18 2017, 4:06 AM
arsenm accepted this revision.Jan 19 2017, 2:13 PM
arsenm added inline comments.
2712–2715 ↗(On Diff #84818)

Should it also be the minimum of the known leading 0s?

This revision is now accepted and ready to land.Jan 19 2017, 2:13 PM

Thanks Matt

2712–2715 ↗(On Diff #84818)

If one input is 0xFFFFxxxx and the other is 0xFxxxxxxx then we know that the UMAX result is at least 0xFFFF0000.

This revision was automatically updated to reflect the committed changes.