[PATCH] D64432: [InstCombine] try to narrow a truncated load

Johannes Doerfert via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jul 14 11:20:15 PDT 2019


jdoerfert added a comment.

In D64432#1582980 <https://reviews.llvm.org/D64432#1582980>, @reames wrote:

> I'm not sure that doing this at the IR level is the best idea.  The problem is that when we narrow, we loose the dereferenceable fact about part of the memory access.  This can in turn limit other transforms which would have been profitable.  As an example:
>  a = load <2 x i8>* p
>  b = load <2 x i8>* (p+1)
>  sum = a[0] + a[1] + b[1]
>
> Narrowing the b load to i8 looses the fact that the memory location corresponding to b[0] is dereferenceable, which would prevent transforms such as:
>  a = load <4 x i8>* p
>  a[2] = 0;
>  sum = horizontal_sum(a);
>
> (Note: I'm not saying this alternate transform is always profitable.  I'm just making a point about lost opportunity.)


Could we check here if the base pointer has `dereferenceable` annotation and use that as a condition for this transformation? (It's more complicated to be completely lossless but this seems to be an easy to test starting point).


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

https://reviews.llvm.org/D64432





More information about the llvm-commits mailing list