[all-commits] [llvm/llvm-project] 6a25e4: [ConstantFolding] Support ptrtoaddr in ConstantFol...

Nikita Popov via All-commits all-commits at lists.llvm.org
Wed Dec 10 23:15:06 PST 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 6a25e454d6443a518e1460a9125ed60d0470fe83
      https://github.com/llvm/llvm-project/commit/6a25e454d6443a518e1460a9125ed60d0470fe83
  Author: Nikita Popov <npopov at redhat.com>
  Date:   2025-12-11 (Thu, 11 Dec 2025)

  Changed paths:
    M llvm/lib/Analysis/ConstantFolding.cpp
    M llvm/test/Transforms/InstSimplify/ptrtoaddr.ll

  Log Message:
  -----------
  [ConstantFolding] Support ptrtoaddr in ConstantFoldCompareInstOperands (#162653)

This folds `icmp (ptrtoaddr x, ptrtoaddr y)` to `icmp (x, y)`, matching
the existing ptrtoint fold. Restrict both folds to only the case where
the result type matches the address type.
    
I think that all folds this can do in practice end up actually being
valid for ptrtoint to a type large than the address size as well, but I
don't really see a way to justify this generically without making
assumptions about what kind of folding the recursive calls may do.

This is based on the icmp semantics specified in
https://github.com/llvm/llvm-project/pull/163936.



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