[llvm] Calculate KnownBits from Metadata correctly for vector loads (PR #128908)

via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 10 07:55:07 PDT 2025


================
@@ -4027,15 +4027,19 @@ KnownBits SelectionDAG::computeKnownBits(SDValue Op, const APInt &DemandedElts,
       // Fill in any known bits from range information. There are 3 types being
       // used. The results VT (same vector elt size as BitWidth), the loaded
       // MemoryVT (which may or may not be vector) and the range VTs original
-      // type. The range matadata needs the full range (i.e
+      // type. The range metadata needs the full range (i.e
       // MemoryVT().getSizeInBits()), which is truncated to the correct elt size
       // if it is know. These are then extended to the original VT sizes below.
       if (const MDNode *MD = LD->getRanges()) {
+        ConstantInt *Lower = mdconst::extract<ConstantInt>(MD->getOperand(0));
+
+        // FIXME: If loads are modified (e.g. type legalization)
----------------
LU-JOHN wrote:

> You're adding the fixme, but this is what this patch is fixing?

This is not the right location for the FIXME.  Type legalization and perhaps other DAG processing does not maintain the consistency between the range metadata type and the load type/width.    This inconsistency causes problems here, but the fix should not be here.  I'll remove the FIXME.

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


More information about the llvm-commits mailing list