[all-commits] [llvm/llvm-project] 8d3856: [ValueTracking] Don't handle ptrtoint with mismatc...

Nikita Popov via All-commits all-commits at lists.llvm.org
Wed Jul 5 03:18:17 PDT 2023

  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 8d3856836cd0aa5c87800b039a8c854b8044a711
  Author: Nikita Popov <npopov at redhat.com>
  Date:   2023-07-05 (Wed, 05 Jul 2023)

  Changed paths:
    M llvm/include/llvm/IR/PatternMatch.h
    M llvm/lib/Analysis/ValueTracking.cpp
    M llvm/unittests/Analysis/ValueTrackingTest.cpp

  Log Message:
  [ValueTracking] Don't handle ptrtoint with mismatches sizes

When processing assumes, we also handle assumes on ptrtoint of the
value. In canonical IR, these will have the same size as the value.
However, in non-canonical IR there may be an implicit zext or
trunc, which results in a bit width mismatch. We currently handle
this by adjusting bitwidth everywhere, but this is fragile and I'm
pretty sure that the way we do this is incorrect for some predicates,
because we effectively end up commuting an ext/trunc and an icmp.

Instead, add an m_PtrToIntSameSize() matcher that will only handle
bitwidth preserving cases. For the bitwidth-changing cases, wait
until they have been canonicalized.

The original handling for this was added purely to prevent crashes
in an earlier implementation which failed to account for this

More information about the All-commits mailing list