[all-commits] [llvm/llvm-project] 8758e5: [ConstantFolding] Fix handling of index width != p...

Nikita Popov via All-commits all-commits at lists.llvm.org
Tue Mar 11 01:02:55 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 8758e5fe47b5cf2d39d94ee6dc8834755c7687d9
      https://github.com/llvm/llvm-project/commit/8758e5fe47b5cf2d39d94ee6dc8834755c7687d9
  Author: Nikita Popov <npopov at redhat.com>
  Date:   2025-03-11 (Tue, 11 Mar 2025)

  Changed paths:
    M llvm/lib/Analysis/ConstantFolding.cpp
    A llvm/test/Transforms/InstSimplify/ConstProp/inttoptr-gep-index-width.ll

  Log Message:
  -----------
  [ConstantFolding] Fix handling of index width != pointer width (#130608)

Per LangRef:

> The offsets are then added to the low bits of the base address up to
the index type width, with silently-wrapping two’s complement
arithmetic. If the pointer size is larger than the index size, this
means that the bits outside the index type width will not be affected.

The transform as implemented was doubly wrong, because it just truncated
the original base pointer to the index width, losing the top bits
entirely. Make sure we preserve the bits and use wrapping arithmetic
within the low bits.



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