[PATCH] D70246: [InstCombine] remove identity shuffle simplification for mask with undefs

Juneyoung Lee via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 14 19:02:23 PST 2019


aqjune added a comment.

In D70246#1746403 <https://reviews.llvm.org/D70246#1746403>, @spatel wrote:

> AFAIK, no - but that's because we were using 'undef' in the docs here:
>  http://llvm.org/docs/LangRef.html#shufflevector-instruction
>  (no mention of poison)


If `%arg[0] = poison`, it seems the current semantics (returning undef when the shuffle mask is undef) cannot explain the transformation.

  %shuf = shufflevector <4 x float> %arg, <4 x float> undef, <4 x i32> <i32 undef, i32 1, i32 2, i32 3>

%shuf[0] is undef, but after transformation,

  %shuf = shufflevector <4 x float> %arg, <4 x float> undef, <4 x i32> <i32 0, i32 1, i32 2, i32 3>

%shuf[0] is poison.

> 
> 
>> If the reason why shufflevector returns undef is simply there was no poison constant, why don't we move toward adding poison constant?
> 
> What steps are needed to make it happen? From the discussion in PR43958, it sounds like adding+using the new constant might take a while? If not, and we can avoid/alter this patch, that would be better for me (no risk of losing optimizations).

Oh, I meant as an ultimate goal. If moving toward poison constant was already discussed in PR43958, then never mind.
After poison constant is added, we can say that having undef as a shuffle mask returns poison, and change existing vector-related constant foldings to return poison constant, and this needs addition of poison constant.


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

https://reviews.llvm.org/D70246





More information about the llvm-commits mailing list