[PATCH] D79234: [ValueTracking] Fix computeKnownBits() with bitwidth-changing ptrtoint

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 1 17:13:31 PDT 2020


nikic created this revision.
nikic added reviewers: spatel, lebedev.ri.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79234

Files:
  lib/Analysis/ValueTracking.cpp
  unittests/Analysis/ValueTrackingTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79234.261458.patch
Type: text/x-patch
Size: 13360 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200502/4ad361f7/attachment.bin>


More information about the llvm-commits mailing list