[all-commits] [llvm/llvm-project] d86fff: [ValueTracking] Fix computeKnownBits() with bitwid...

Nikita Popov via All-commits all-commits at lists.llvm.org
Sat May 16 05:19:20 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: d86fff6ae7cfd6666511e9c2129711b88ed514be
      https://github.com/llvm/llvm-project/commit/d86fff6ae7cfd6666511e9c2129711b88ed514be
  Author: Nikita Popov <nikita.ppv at gmail.com>
  Date:   2020-05-16 (Sat, 16 May 2020)

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

  Log Message:
  -----------
  [ValueTracking] Fix computeKnownBits() with bitwidth-changing ptrtoint

computeKnownBitsFromAssume() currently asserts if m_V matches a
ptrtoint that changes the bitwidth. Because InstCombine
canonicalizes ptrtoint instructions to use explicit zext/trunc,
we never ran into the issue in practice. I'm adding unit tests,
as I don't know if this can be triggered via IR anywhere.

Fix this by calling anyextOrTrunc(BitWidth) on the computed
KnownBits. Note that we are going from the KnownBits of the
ptrtoint result to the KnownBits of the ptrtoint operand,
so we need to truncate if the ptrtoint zexted and anyext if
the ptrtoint truncated.

Differential Revision: https://reviews.llvm.org/D79234




More information about the All-commits mailing list