1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -show-mc-encoding -mattr=+sse2 | FileCheck %s --check-prefix=SSE
3 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -show-mc-encoding -mattr=+avx | FileCheck %s --check-prefix=AVX
4 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -show-mc-encoding -mattr=+avx512dq,+avx512vl | FileCheck %s --check-prefix=AVX512DQ
6 ; Test that we can replace "scalar" FP-bitwise-logic with the optimal instruction.
7 ; Scalar x86 FP-logic instructions only exist in your imagination and/or the bowels
8 ; of compilers, but float and double variants of FP-logic instructions are reality
9 ; and float may be a shorter instruction depending on which flavor of vector ISA
10 ; you have...so just prefer float all the time, ok? Yay, x86!
12 define double @FsANDPSrr(double %x, double %y) {
13 ; SSE-LABEL: FsANDPSrr:
15 ; SSE-NEXT: andps %xmm1, %xmm0 # encoding: [0x0f,0x54,0xc1]
16 ; SSE-NEXT: retq # encoding: [0xc3]
18 ; AVX-LABEL: FsANDPSrr:
20 ; AVX-NEXT: vandps %xmm1, %xmm0, %xmm0 # encoding: [0xc5,0xf8,0x54,0xc1]
21 ; AVX-NEXT: retq # encoding: [0xc3]
23 ; AVX512DQ-LABEL: FsANDPSrr:
25 ; AVX512DQ-NEXT: vandps %xmm1, %xmm0, %xmm0 # EVEX TO VEX Compression encoding: [0xc5,0xf8,0x54,0xc1]
26 ; AVX512DQ-NEXT: retq # encoding: [0xc3]
27 %bc1 = bitcast double %x to i64
28 %bc2 = bitcast double %y to i64
29 %and = and i64 %bc1, %bc2
30 %bc3 = bitcast i64 %and to double
34 define double @FsANDNPSrr(double %x, double %y) {
35 ; SSE-LABEL: FsANDNPSrr:
37 ; SSE-NEXT: andnps %xmm0, %xmm1 # encoding: [0x0f,0x55,0xc8]
38 ; SSE-NEXT: movaps %xmm1, %xmm0 # encoding: [0x0f,0x28,0xc1]
39 ; SSE-NEXT: retq # encoding: [0xc3]
41 ; AVX-LABEL: FsANDNPSrr:
43 ; AVX-NEXT: vandnps %xmm0, %xmm1, %xmm0 # encoding: [0xc5,0xf0,0x55,0xc0]
44 ; AVX-NEXT: retq # encoding: [0xc3]
46 ; AVX512DQ-LABEL: FsANDNPSrr:
48 ; AVX512DQ-NEXT: vandnps %xmm0, %xmm1, %xmm0 # EVEX TO VEX Compression encoding: [0xc5,0xf0,0x55,0xc0]
49 ; AVX512DQ-NEXT: retq # encoding: [0xc3]
50 %bc1 = bitcast double %x to i64
51 %bc2 = bitcast double %y to i64
52 %not = xor i64 %bc2, -1
53 %and = and i64 %bc1, %not
54 %bc3 = bitcast i64 %and to double
58 define double @FsORPSrr(double %x, double %y) {
59 ; SSE-LABEL: FsORPSrr:
61 ; SSE-NEXT: orps %xmm1, %xmm0 # encoding: [0x0f,0x56,0xc1]
62 ; SSE-NEXT: retq # encoding: [0xc3]
64 ; AVX-LABEL: FsORPSrr:
66 ; AVX-NEXT: vorps %xmm1, %xmm0, %xmm0 # encoding: [0xc5,0xf8,0x56,0xc1]
67 ; AVX-NEXT: retq # encoding: [0xc3]
69 ; AVX512DQ-LABEL: FsORPSrr:
71 ; AVX512DQ-NEXT: vorps %xmm1, %xmm0, %xmm0 # EVEX TO VEX Compression encoding: [0xc5,0xf8,0x56,0xc1]
72 ; AVX512DQ-NEXT: retq # encoding: [0xc3]
73 %bc1 = bitcast double %x to i64
74 %bc2 = bitcast double %y to i64
75 %or = or i64 %bc1, %bc2
76 %bc3 = bitcast i64 %or to double
80 define double @FsXORPSrr(double %x, double %y) {
81 ; SSE-LABEL: FsXORPSrr:
83 ; SSE-NEXT: xorps %xmm1, %xmm0 # encoding: [0x0f,0x57,0xc1]
84 ; SSE-NEXT: retq # encoding: [0xc3]
86 ; AVX-LABEL: FsXORPSrr:
88 ; AVX-NEXT: vxorps %xmm1, %xmm0, %xmm0 # encoding: [0xc5,0xf8,0x57,0xc1]
89 ; AVX-NEXT: retq # encoding: [0xc3]
91 ; AVX512DQ-LABEL: FsXORPSrr:
93 ; AVX512DQ-NEXT: vxorps %xmm1, %xmm0, %xmm0 # EVEX TO VEX Compression encoding: [0xc5,0xf8,0x57,0xc1]
94 ; AVX512DQ-NEXT: retq # encoding: [0xc3]
95 %bc1 = bitcast double %x to i64
96 %bc2 = bitcast double %y to i64
97 %xor = xor i64 %bc1, %bc2
98 %bc3 = bitcast i64 %xor to double