Sanjay Patel | 9d13a18 | 2017-06-12 17:05:43 +0000 | [diff] [blame] | 1 | ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py |
Craig Topper | 81b021e | 2016-12-17 19:25:55 +0000 | [diff] [blame] | 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 |
Craig Topper | 2baef8f | 2016-12-18 04:17:00 +0000 | [diff] [blame] | 4 | ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -show-mc-encoding -mattr=+avx512dq,+avx512vl | FileCheck %s --check-prefix=AVX512DQ |
Sanjay Patel | 2a51748 | 2016-11-15 21:19:28 +0000 | [diff] [blame] | 5 | |
| 6 | ; Test that we can replace "scalar" FP-bitwise-logic with the optimal instruction. |
Sanjay Patel | 7f3d51f | 2016-11-16 17:42:40 +0000 | [diff] [blame] | 7 | ; Scalar x86 FP-logic instructions only exist in your imagination and/or the bowels |
Sanjay Patel | 2a51748 | 2016-11-15 21:19:28 +0000 | [diff] [blame] | 8 | ; of compilers, but float and double variants of FP-logic instructions are reality |
Sanjay Patel | 7f3d51f | 2016-11-16 17:42:40 +0000 | [diff] [blame] | 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! |
Sanjay Patel | 2a51748 | 2016-11-15 21:19:28 +0000 | [diff] [blame] | 11 | |
| 12 | define double @FsANDPSrr(double %x, double %y) { |
| 13 | ; SSE-LABEL: FsANDPSrr: |
Francis Visoiu Mistrih | 25528d6 | 2017-12-04 17:18:51 +0000 | [diff] [blame^] | 14 | ; SSE: # %bb.0: |
Craig Topper | 81b021e | 2016-12-17 19:25:55 +0000 | [diff] [blame] | 15 | ; SSE-NEXT: andps %xmm1, %xmm0 # encoding: [0x0f,0x54,0xc1] |
| 16 | ; SSE-NEXT: retq # encoding: [0xc3] |
Sanjay Patel | 2a51748 | 2016-11-15 21:19:28 +0000 | [diff] [blame] | 17 | ; |
| 18 | ; AVX-LABEL: FsANDPSrr: |
Francis Visoiu Mistrih | 25528d6 | 2017-12-04 17:18:51 +0000 | [diff] [blame^] | 19 | ; AVX: # %bb.0: |
Craig Topper | 81b021e | 2016-12-17 19:25:55 +0000 | [diff] [blame] | 20 | ; AVX-NEXT: vandps %xmm1, %xmm0, %xmm0 # encoding: [0xc5,0xf8,0x54,0xc1] |
| 21 | ; AVX-NEXT: retq # encoding: [0xc3] |
| 22 | ; |
| 23 | ; AVX512DQ-LABEL: FsANDPSrr: |
Francis Visoiu Mistrih | 25528d6 | 2017-12-04 17:18:51 +0000 | [diff] [blame^] | 24 | ; AVX512DQ: # %bb.0: |
Gadi Haber | 19c4fc5 | 2016-12-28 10:12:48 +0000 | [diff] [blame] | 25 | ; AVX512DQ-NEXT: vandps %xmm1, %xmm0, %xmm0 # EVEX TO VEX Compression encoding: [0xc5,0xf8,0x54,0xc1] |
Craig Topper | 81b021e | 2016-12-17 19:25:55 +0000 | [diff] [blame] | 26 | ; AVX512DQ-NEXT: retq # encoding: [0xc3] |
Sanjay Patel | 2a51748 | 2016-11-15 21:19:28 +0000 | [diff] [blame] | 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 |
| 31 | ret double %bc3 |
| 32 | } |
| 33 | |
| 34 | define double @FsANDNPSrr(double %x, double %y) { |
| 35 | ; SSE-LABEL: FsANDNPSrr: |
Francis Visoiu Mistrih | 25528d6 | 2017-12-04 17:18:51 +0000 | [diff] [blame^] | 36 | ; SSE: # %bb.0: |
Craig Topper | 81b021e | 2016-12-17 19:25:55 +0000 | [diff] [blame] | 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] |
Sanjay Patel | 2a51748 | 2016-11-15 21:19:28 +0000 | [diff] [blame] | 40 | ; |
| 41 | ; AVX-LABEL: FsANDNPSrr: |
Francis Visoiu Mistrih | 25528d6 | 2017-12-04 17:18:51 +0000 | [diff] [blame^] | 42 | ; AVX: # %bb.0: |
Craig Topper | 81b021e | 2016-12-17 19:25:55 +0000 | [diff] [blame] | 43 | ; AVX-NEXT: vandnps %xmm0, %xmm1, %xmm0 # encoding: [0xc5,0xf0,0x55,0xc0] |
| 44 | ; AVX-NEXT: retq # encoding: [0xc3] |
| 45 | ; |
| 46 | ; AVX512DQ-LABEL: FsANDNPSrr: |
Francis Visoiu Mistrih | 25528d6 | 2017-12-04 17:18:51 +0000 | [diff] [blame^] | 47 | ; AVX512DQ: # %bb.0: |
Gadi Haber | 19c4fc5 | 2016-12-28 10:12:48 +0000 | [diff] [blame] | 48 | ; AVX512DQ-NEXT: vandnps %xmm0, %xmm1, %xmm0 # EVEX TO VEX Compression encoding: [0xc5,0xf0,0x55,0xc0] |
Craig Topper | 81b021e | 2016-12-17 19:25:55 +0000 | [diff] [blame] | 49 | ; AVX512DQ-NEXT: retq # encoding: [0xc3] |
Sanjay Patel | 2a51748 | 2016-11-15 21:19:28 +0000 | [diff] [blame] | 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 |
| 55 | ret double %bc3 |
| 56 | } |
| 57 | |
| 58 | define double @FsORPSrr(double %x, double %y) { |
| 59 | ; SSE-LABEL: FsORPSrr: |
Francis Visoiu Mistrih | 25528d6 | 2017-12-04 17:18:51 +0000 | [diff] [blame^] | 60 | ; SSE: # %bb.0: |
Craig Topper | 81b021e | 2016-12-17 19:25:55 +0000 | [diff] [blame] | 61 | ; SSE-NEXT: orps %xmm1, %xmm0 # encoding: [0x0f,0x56,0xc1] |
| 62 | ; SSE-NEXT: retq # encoding: [0xc3] |
Sanjay Patel | 2a51748 | 2016-11-15 21:19:28 +0000 | [diff] [blame] | 63 | ; |
| 64 | ; AVX-LABEL: FsORPSrr: |
Francis Visoiu Mistrih | 25528d6 | 2017-12-04 17:18:51 +0000 | [diff] [blame^] | 65 | ; AVX: # %bb.0: |
Craig Topper | 81b021e | 2016-12-17 19:25:55 +0000 | [diff] [blame] | 66 | ; AVX-NEXT: vorps %xmm1, %xmm0, %xmm0 # encoding: [0xc5,0xf8,0x56,0xc1] |
| 67 | ; AVX-NEXT: retq # encoding: [0xc3] |
| 68 | ; |
| 69 | ; AVX512DQ-LABEL: FsORPSrr: |
Francis Visoiu Mistrih | 25528d6 | 2017-12-04 17:18:51 +0000 | [diff] [blame^] | 70 | ; AVX512DQ: # %bb.0: |
Gadi Haber | 19c4fc5 | 2016-12-28 10:12:48 +0000 | [diff] [blame] | 71 | ; AVX512DQ-NEXT: vorps %xmm1, %xmm0, %xmm0 # EVEX TO VEX Compression encoding: [0xc5,0xf8,0x56,0xc1] |
Craig Topper | 81b021e | 2016-12-17 19:25:55 +0000 | [diff] [blame] | 72 | ; AVX512DQ-NEXT: retq # encoding: [0xc3] |
Sanjay Patel | 2a51748 | 2016-11-15 21:19:28 +0000 | [diff] [blame] | 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 |
| 77 | ret double %bc3 |
| 78 | } |
| 79 | |
| 80 | define double @FsXORPSrr(double %x, double %y) { |
| 81 | ; SSE-LABEL: FsXORPSrr: |
Francis Visoiu Mistrih | 25528d6 | 2017-12-04 17:18:51 +0000 | [diff] [blame^] | 82 | ; SSE: # %bb.0: |
Craig Topper | 81b021e | 2016-12-17 19:25:55 +0000 | [diff] [blame] | 83 | ; SSE-NEXT: xorps %xmm1, %xmm0 # encoding: [0x0f,0x57,0xc1] |
| 84 | ; SSE-NEXT: retq # encoding: [0xc3] |
Sanjay Patel | 2a51748 | 2016-11-15 21:19:28 +0000 | [diff] [blame] | 85 | ; |
| 86 | ; AVX-LABEL: FsXORPSrr: |
Francis Visoiu Mistrih | 25528d6 | 2017-12-04 17:18:51 +0000 | [diff] [blame^] | 87 | ; AVX: # %bb.0: |
Craig Topper | 81b021e | 2016-12-17 19:25:55 +0000 | [diff] [blame] | 88 | ; AVX-NEXT: vxorps %xmm1, %xmm0, %xmm0 # encoding: [0xc5,0xf8,0x57,0xc1] |
| 89 | ; AVX-NEXT: retq # encoding: [0xc3] |
| 90 | ; |
| 91 | ; AVX512DQ-LABEL: FsXORPSrr: |
Francis Visoiu Mistrih | 25528d6 | 2017-12-04 17:18:51 +0000 | [diff] [blame^] | 92 | ; AVX512DQ: # %bb.0: |
Gadi Haber | 19c4fc5 | 2016-12-28 10:12:48 +0000 | [diff] [blame] | 93 | ; AVX512DQ-NEXT: vxorps %xmm1, %xmm0, %xmm0 # EVEX TO VEX Compression encoding: [0xc5,0xf8,0x57,0xc1] |
Craig Topper | 81b021e | 2016-12-17 19:25:55 +0000 | [diff] [blame] | 94 | ; AVX512DQ-NEXT: retq # encoding: [0xc3] |
Sanjay Patel | 2a51748 | 2016-11-15 21:19:28 +0000 | [diff] [blame] | 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 |
| 99 | ret double %bc3 |
| 100 | } |
| 101 | |