[PATCH] D64768: [InstructionSimplify] Apply sext/trunc after pointer stripping

Michael Liao via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 15 15:16:17 PDT 2019


hliao added a comment.

In D64768#1586435 <https://reviews.llvm.org/D64768#1586435>, @jdoerfert wrote:

> This is fine with me. Though, I'm unsure if this should not live in the `stripAndAccumulateConstantOffsets` method.
>
> The problem is that we have two bit-widths now, pointer before and after. Since we have to express offset in one of them, we have a choice.
>  I think we already guarantee that the offset is representable in the initial bit-width so that was what I choose. Question is, do we want
>  to change it to be in the resulting bit-width or not. Either way, we should add a comment to the stripAndAccumulateConstantOffsets method
>  explaining the situation.


As I mentioned, without this fix, there are crashes when compiling similar patterns. The issue is that LHS gets the original bit-width as the offset is 0 and RHS gets the one after stripping. Later, as the stripped pointers point the same object, instsimplify will create compare of the offset, that triggers the crash. We have to ensure offset after stripping has the same bit-width.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64768





More information about the llvm-commits mailing list