[PATCH] D79528: [ConstantFold] Optimize xor undef, undef to undef
Sanjay Patel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu May 7 05:38:01 PDT 2020
spatel added a comment.
In D79528#2023931 <https://reviews.llvm.org/D79528#2023931>, @efriedma wrote:
> This is correct, strictly speaking, but has the situation with misguided users really improved any? That same code using _mm_xor_ps() or whatever to zero __m128 variables is probably still out there, and clang still doesn't print any diagnostic by default if you try to do that. And this still isn't really a useful fold.
Clang does recognize this given the right flags, but I agree there's more risk than reward here - folding to "0" should be almost as effective for optimization. There's code out there that will probably start misbehaving in very difficult-to-diagnose ways if we do this.
$ cat xor.c
#include <xmmintrin.h>
int f() {
int x;
return x ^ x;
}
__m128 g() {
__m128 x;
return _mm_xor_si128(x, x);
}
$ ./clang xor.c -c
$ ./clang xor.c -c -Wall
xor.c:5:10: warning: variable 'x' is uninitialized when used here [-Wuninitialized]
return x ^ x;
^
xor.c:4:8: note: initialize the variable 'x' to silence this warning
int x;
^
= 0
xor.c:10:24: warning: variable 'x' is uninitialized when used here [-Wuninitialized]
return _mm_xor_si128(x, x);
^
xor.c:9:3: note: variable 'x' is declared here
__m128 x;
^
2 warnings generated.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D79528/new/
https://reviews.llvm.org/D79528
More information about the llvm-commits
mailing list