[PATCH] D119740: [InstructionSimplify][FIX] Handle bit widths in the presence of AS-casts

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 16 01:12:22 PST 2022


nikic added a comment.

In D119740#3323013 <https://reviews.llvm.org/D119740#3323013>, @jdoerfert wrote:

> In D119740#3322389 <https://reviews.llvm.org/D119740#3322389>, @nikic wrote:
>
>> Does https://github.com/llvm/llvm-project/commit/f35af77573d9e80bf6e61b3fdd20fe55191e962f fix your original problem?
>
> It makes it easier to fix but without testing it I would not assume the issue is gone.
> The strip calls can still yield constants with different bit-width as they are matched to the bit-width of the resulting value.
> So LHS/RHS that come out of the strip call can have different types and address spaces, and the constant offsets can have different bit-widths.

The reason why I'd expect it to be fixed is that RHSOffset and LHSOffset only get used together if RHS == LHS now, in which case the type of the (offset-stripped) pointers match and as such should also have the same index size.

> If we always return the constants with bit-widths matching the inputs (which I do here), the only remaining problem is that we call `stripPointerCasts` first, which causes the LHS/RHS to be "not in sync" when we call stripAndAccumulate. (see my comment in the code).

Not just that, but computePointerICmp() itself may be called on different types -- apparently, it looks through ptrtoint.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119740



More information about the llvm-commits mailing list