[all-commits] [llvm/llvm-project] 3bd11b: [ValueTracking] Fix bit width handling in computeK...

Nikita Popov via All-commits all-commits at lists.llvm.org
Tue Feb 4 05:30:20 PST 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 3bd11b502c1846afa5e1257c94b7a70566e34686
      https://github.com/llvm/llvm-project/commit/3bd11b502c1846afa5e1257c94b7a70566e34686
  Author: Nikita Popov <npopov at redhat.com>
  Date:   2025-02-04 (Tue, 04 Feb 2025)

  Changed paths:
    M llvm/lib/Analysis/ValueTracking.cpp
    M llvm/unittests/Analysis/ValueTrackingTest.cpp

  Log Message:
  -----------
  [ValueTracking] Fix bit width handling in computeKnownBits() for GEPs (#125532)

For GEPs, we have three bit widths involved: The pointer bit width, the
index bit width, and the bit width of the GEP operands.

The correct behavior here is:
* We need to sextOrTrunc the GEP operand to the index width *before*
multiplying by the scale.
* If the index width and pointer width differ, GEP only ever modifies
the low bits. Adds should not overflow into the high bits.

I'm testing this via unit tests because it's a bit tricky to test in IR
with InstCombine canonicalization getting in the way.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list