This is an archive of the discontinued LLVM Phabricator instance.

[DAGCombiner][RISCV] Improve computeKnownBits for (smin X, C) where C is negative.
AbandonedPublic

Authored by Pretty-box on Jun 5 2022, 8:22 PM.

Details

Summary

[DAGCombiner][RISCV] Improve computeKnownBits for (smin X, C) where C is negative.

If C is negative, the result of the smin must also be
negative, so all sign bits of the result are 1.

Diff Detail

Event Timeline

Pretty-box created this revision.Jun 5 2022, 8:22 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 5 2022, 8:22 PM
Pretty-box requested review of this revision.Jun 5 2022, 8:22 PM

Pre-commit the test?

llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
3713

CstHigh and CstLow might have been swapped on line 368.

llvm/test/CodeGen/RISCV/min-max.ll
642

pos here meant positive. This is a negative constant.

craig.topper added inline comments.Jun 5 2022, 8:43 PM
llvm/test/CodeGen/RISCV/min-max.ll
655

This is the code we get without this patch. That's why I didn't bother with the smin case.

Pretty-box abandoned this revision.Jun 7 2022, 7:49 PM