Issue 202756
Summary [X86] Suboptimal generation of same-argument cmpunord
Labels
Assignees
Reporter dzaima
    The code:

```c
#include<immintrin.h>
__m256d f(__m256d a) {
    return _mm256_cmp_pd(a, a, 3);
}
```

gets compiled to:

```asm
 vxorpd  xmm1, xmm1, xmm1
        vcmpunordpd     ymm0, ymm0, ymm1
 ret
```

despite being trivially better as explicitly written:
```asm
 vcmpunordpd  ymm0, ymm0, ymm0
 ret
```

https://godbolt.org/z/z7WsY1Yb6

IR from middle-end:
```llvm
define noundef <4 x double> @f(<4 x double> noundef %a) {
  %0 = fcmp uno <4 x double> %a, zeroinitializer
  %1 = sext <4 x i1> %0 to <4 x i64>
  %2 = bitcast <4 x i64> %1 to <4 x double>
  ret <4 x double> %2
}
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to