When the shift amount is known and a known sign bit analysis of
the shiftee indicates that no saturation will occur, then we can
replace SSHLSAT/USHLSAT by SHL.
Details
Details
Diff Detail
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | ||
---|---|---|
9354 | Maybe I need to check that the SHL is legal/custom (unless this is before legalization). |
Comment Actions
a few minors
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | ||
---|---|---|
9354 | We've been hit in the past by fuzzers which think its funny to create constants greater than i64 - so maybe: N1->getAPIntValue().ult(DAG.ComputeNumSignBits(N0)) | |
9359 | N1->getAPIntValue().ult(BitWidth) && | |
9361 | It might be easier to grok as this? DAG.computeKnownBits(N0).getMaxValue().ult(N1C->getZExtValue()) |
Comment Actions
Updated after review feedback:
- Now using APInt for comparisons.
- For USHLSAT we now compare minimum number of known leading zeroes to the shift amount when checking if all shifted out bits are zero. That is hopefully easier to read/understand compared to using MaskedValueIsZero.
Maybe I need to check that the SHL is legal/custom (unless this is before legalization).