[PATCH] D79452: [VectorCombine] scalarize binop of inserted elements into undef
Sanjay Patel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed May 6 06:25:01 PDT 2020
spatel added subscribers: aqjune, regehr, nlopes.
spatel added a comment.
In D79452#2022321 <https://reviews.llvm.org/D79452#2022321>, @RKSimon wrote:
> Random question - what about special case undef handling for the upper elements?
>
> opt -instcombine
>
> define i32 @square() {
> %1 = xor i32 undef, undef
> ret i32 %1
> }
> ->
> define i32 @square() {
> ret i32 0
> }
>
cc'ing @aqjune @nlopes @regehr
undef ^ undef is actually undef:
http://volta.cs.utah.edu:8080/z/GAs5QJ
But I think we choose to fold to "0" on that to avoid breaking too much existing source code and/or expose possible semantic incompatibility with source code?
In the original vector code here, we're not performing the binop on the *same* value because 'undef' is an arbitrary bit pattern in each instruction:
http://volta.cs.utah.edu:8080/z/eqrVkm
I was assuming that we don't have the same concern about vector code as the scalar code here, but we could use ConstantFolding to generate the result for each element of the output vector.
But that will definitely need to be handled when we generalize this to deal with non-undef constants with something like the code from D50992 <https://reviews.llvm.org/D50992>.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D79452/new/
https://reviews.llvm.org/D79452
More information about the llvm-commits
mailing list