[llvm] [GlobalISel] Add computeNumSignBits for ASHR (PR #139503)
Jay Foad via llvm-commits
llvm-commits at lists.llvm.org
Thu May 22 01:03:59 PDT 2025
================
@@ -87,6 +87,20 @@ class GISelValueTracking : public GISelChangeObserver {
/// \return The known alignment for the pointer-like value \p R.
Align computeKnownAlignment(Register R, unsigned Depth = 0);
+ /// If a G_SHL/G_ASHR/G_LSHR node with shift operand \p R has shift amounts
+ /// that are all less than the element bit-width of the shift node, return the
+ /// valid constant range.
+ std::optional<ConstantRange>
+ getValidShiftAmountRange(Register R, const APInt &DemandedElts,
+ unsigned Depth);
+
+ /// If a G_SHL/G_ASHR/G_LSHR node with shift operand \p R has shift amounts
+ /// that are all less than the element bit-width of the shift node, return the
+ /// minimum possible value.
+ std::optional<uint64_t> getValidMinimumShiftAmount(Register R,
+ const APInt &DemandedElts,
+ unsigned Depth = 0);
+
----------------
jayfoad wrote:
This can't work. These functions don't know "the element bit-width of the shift node". You can't deduce it from `R` because (unlike in IR) G_ASHR can have different types for its two operands.
https://github.com/llvm/llvm-project/pull/139503
More information about the llvm-commits
mailing list