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

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 6 01:02:39 PDT 2020


nikic added a subscriber: efriedma.
nikic added a comment.

In D79234#2022052 <https://reviews.llvm.org/D79234#2022052>, @lebedev.ri wrote:

> Is this fixing some bug? Is there an observable behavior change?
>  Can a (currently-crashing) test be added for some pass?
>  Or can this only be triggered via a specially-crafted unit test?


This fixes a bug. There is no behavior change. It can be observed in IR by moving known bits alignment calculation from InstCombine into AlignmentFromAssumptions. It cannot be observed in InstCombine because InstCombine canonicalizes ptrtoint casts to explicit zext/trunc. Maybe it can be observed in some other pass, but it's not easy (we need both non-trivial context instruction for assumes, and known bits query on a pointer value, which is unusual).

Maybe the better way of "fixing" this issue is to change IR definition of ptrtoint/inttoptr to forbid bitwidth change and always require zext/trunc? I have no idea why the current semantics exist. Maybe @efriedma knows?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79234/new/

https://reviews.llvm.org/D79234





More information about the llvm-commits mailing list