[llvm] [GlobalISel] Add computeNumSignBits for ASHR (PR #139503)

David Green via llvm-commits llvm-commits at lists.llvm.org
Mon May 26 00:40:57 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);
+
----------------
davemgreen wrote:

Ah Right - I think that is still causing us problems elsewhere too. I've updated to plumb a BitWidth through.

https://github.com/llvm/llvm-project/pull/139503


More information about the llvm-commits mailing list