blob: c1660ea696f4274f0fc914a148b0507932c9ad1f [file] [log] [blame]
Sanjay Patel9d13a182017-06-12 17:05:43 +00001; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
Craig Topper81b021e2016-12-17 19:25:55 +00002; 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
Craig Topper2baef8f2016-12-18 04:17:00 +00004; RUN: llc < %s -mtriple=x86_64-unknown-unknown -show-mc-encoding -mattr=+avx512dq,+avx512vl | FileCheck %s --check-prefix=AVX512DQ
Sanjay Patel2a517482016-11-15 21:19:28 +00005
6; Test that we can replace "scalar" FP-bitwise-logic with the optimal instruction.
Sanjay Patel7f3d51f2016-11-16 17:42:40 +00007; Scalar x86 FP-logic instructions only exist in your imagination and/or the bowels
Sanjay Patel2a517482016-11-15 21:19:28 +00008; of compilers, but float and double variants of FP-logic instructions are reality
Sanjay Patel7f3d51f2016-11-16 17:42:40 +00009; 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!
Sanjay Patel2a517482016-11-15 21:19:28 +000011
12define double @FsANDPSrr(double %x, double %y) {
13; SSE-LABEL: FsANDPSrr:
Francis Visoiu Mistrih25528d62017-12-04 17:18:51 +000014; SSE: # %bb.0:
Craig Topper81b021e2016-12-17 19:25:55 +000015; SSE-NEXT: andps %xmm1, %xmm0 # encoding: [0x0f,0x54,0xc1]
16; SSE-NEXT: retq # encoding: [0xc3]
Sanjay Patel2a517482016-11-15 21:19:28 +000017;
18; AVX-LABEL: FsANDPSrr:
Francis Visoiu Mistrih25528d62017-12-04 17:18:51 +000019; AVX: # %bb.0:
Craig Topper81b021e2016-12-17 19:25:55 +000020; AVX-NEXT: vandps %xmm1, %xmm0, %xmm0 # encoding: [0xc5,0xf8,0x54,0xc1]
21; AVX-NEXT: retq # encoding: [0xc3]
22;
23; AVX512DQ-LABEL: FsANDPSrr:
Francis Visoiu Mistrih25528d62017-12-04 17:18:51 +000024; AVX512DQ: # %bb.0:
Gadi Haber19c4fc52016-12-28 10:12:48 +000025; AVX512DQ-NEXT: vandps %xmm1, %xmm0, %xmm0 # EVEX TO VEX Compression encoding: [0xc5,0xf8,0x54,0xc1]
Craig Topper81b021e2016-12-17 19:25:55 +000026; AVX512DQ-NEXT: retq # encoding: [0xc3]
Sanjay Patel2a517482016-11-15 21:19:28 +000027 %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
31 ret double %bc3
32}
33
34define double @FsANDNPSrr(double %x, double %y) {
35; SSE-LABEL: FsANDNPSrr:
Francis Visoiu Mistrih25528d62017-12-04 17:18:51 +000036; SSE: # %bb.0:
Craig Topper81b021e2016-12-17 19:25:55 +000037; 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]
Sanjay Patel2a517482016-11-15 21:19:28 +000040;
41; AVX-LABEL: FsANDNPSrr:
Francis Visoiu Mistrih25528d62017-12-04 17:18:51 +000042; AVX: # %bb.0:
Craig Topper81b021e2016-12-17 19:25:55 +000043; AVX-NEXT: vandnps %xmm0, %xmm1, %xmm0 # encoding: [0xc5,0xf0,0x55,0xc0]
44; AVX-NEXT: retq # encoding: [0xc3]
45;
46; AVX512DQ-LABEL: FsANDNPSrr:
Francis Visoiu Mistrih25528d62017-12-04 17:18:51 +000047; AVX512DQ: # %bb.0:
Gadi Haber19c4fc52016-12-28 10:12:48 +000048; AVX512DQ-NEXT: vandnps %xmm0, %xmm1, %xmm0 # EVEX TO VEX Compression encoding: [0xc5,0xf0,0x55,0xc0]
Craig Topper81b021e2016-12-17 19:25:55 +000049; AVX512DQ-NEXT: retq # encoding: [0xc3]
Sanjay Patel2a517482016-11-15 21:19:28 +000050 %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
55 ret double %bc3
56}
57
58define double @FsORPSrr(double %x, double %y) {
59; SSE-LABEL: FsORPSrr:
Francis Visoiu Mistrih25528d62017-12-04 17:18:51 +000060; SSE: # %bb.0:
Craig Topper81b021e2016-12-17 19:25:55 +000061; SSE-NEXT: orps %xmm1, %xmm0 # encoding: [0x0f,0x56,0xc1]
62; SSE-NEXT: retq # encoding: [0xc3]
Sanjay Patel2a517482016-11-15 21:19:28 +000063;
64; AVX-LABEL: FsORPSrr:
Francis Visoiu Mistrih25528d62017-12-04 17:18:51 +000065; AVX: # %bb.0:
Craig Topper81b021e2016-12-17 19:25:55 +000066; AVX-NEXT: vorps %xmm1, %xmm0, %xmm0 # encoding: [0xc5,0xf8,0x56,0xc1]
67; AVX-NEXT: retq # encoding: [0xc3]
68;
69; AVX512DQ-LABEL: FsORPSrr:
Francis Visoiu Mistrih25528d62017-12-04 17:18:51 +000070; AVX512DQ: # %bb.0:
Gadi Haber19c4fc52016-12-28 10:12:48 +000071; AVX512DQ-NEXT: vorps %xmm1, %xmm0, %xmm0 # EVEX TO VEX Compression encoding: [0xc5,0xf8,0x56,0xc1]
Craig Topper81b021e2016-12-17 19:25:55 +000072; AVX512DQ-NEXT: retq # encoding: [0xc3]
Sanjay Patel2a517482016-11-15 21:19:28 +000073 %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
77 ret double %bc3
78}
79
80define double @FsXORPSrr(double %x, double %y) {
81; SSE-LABEL: FsXORPSrr:
Francis Visoiu Mistrih25528d62017-12-04 17:18:51 +000082; SSE: # %bb.0:
Craig Topper81b021e2016-12-17 19:25:55 +000083; SSE-NEXT: xorps %xmm1, %xmm0 # encoding: [0x0f,0x57,0xc1]
84; SSE-NEXT: retq # encoding: [0xc3]
Sanjay Patel2a517482016-11-15 21:19:28 +000085;
86; AVX-LABEL: FsXORPSrr:
Francis Visoiu Mistrih25528d62017-12-04 17:18:51 +000087; AVX: # %bb.0:
Craig Topper81b021e2016-12-17 19:25:55 +000088; AVX-NEXT: vxorps %xmm1, %xmm0, %xmm0 # encoding: [0xc5,0xf8,0x57,0xc1]
89; AVX-NEXT: retq # encoding: [0xc3]
90;
91; AVX512DQ-LABEL: FsXORPSrr:
Francis Visoiu Mistrih25528d62017-12-04 17:18:51 +000092; AVX512DQ: # %bb.0:
Gadi Haber19c4fc52016-12-28 10:12:48 +000093; AVX512DQ-NEXT: vxorps %xmm1, %xmm0, %xmm0 # EVEX TO VEX Compression encoding: [0xc5,0xf8,0x57,0xc1]
Craig Topper81b021e2016-12-17 19:25:55 +000094; AVX512DQ-NEXT: retq # encoding: [0xc3]
Sanjay Patel2a517482016-11-15 21:19:28 +000095 %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
99 ret double %bc3
100}
101