1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187
|
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+bmi,+bmi2 | FileCheck %s --check-prefixes=CHECK
; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+bmi,+bmi2,egpr --show-mc-encoding | FileCheck %s --check-prefixes=EGPR
define i64 @bzhi64(i64 %x, i64 %y) {
; CHECK-LABEL: bzhi64:
; CHECK: # %bb.0:
; CHECK-NEXT: bzhiq %rsi, %rdi, %rax
; CHECK-NEXT: retq
;
; EGPR-LABEL: bzhi64:
; EGPR: # %bb.0:
; EGPR-NEXT: bzhiq %rsi, %rdi, %rax # EVEX TO VEX Compression encoding: [0xc4,0xe2,0xc8,0xf5,0xc7]
; EGPR-NEXT: retq # encoding: [0xc3]
%tmp = tail call i64 @llvm.x86.bmi.bzhi.64(i64 %x, i64 %y)
ret i64 %tmp
}
define i64 @bzhi64_load(ptr %x, i64 %y) {
; CHECK-LABEL: bzhi64_load:
; CHECK: # %bb.0:
; CHECK-NEXT: bzhiq %rsi, (%rdi), %rax
; CHECK-NEXT: retq
;
; EGPR-LABEL: bzhi64_load:
; EGPR: # %bb.0:
; EGPR-NEXT: bzhiq %rsi, (%rdi), %rax # EVEX TO VEX Compression encoding: [0xc4,0xe2,0xc8,0xf5,0x07]
; EGPR-NEXT: retq # encoding: [0xc3]
%x1 = load i64, ptr %x
%tmp = tail call i64 @llvm.x86.bmi.bzhi.64(i64 %x1, i64 %y)
ret i64 %tmp
}
declare i64 @llvm.x86.bmi.bzhi.64(i64, i64)
define i64 @pdep64(i64 %x, i64 %y) {
; CHECK-LABEL: pdep64:
; CHECK: # %bb.0:
; CHECK-NEXT: pdepq %rsi, %rdi, %rax
; CHECK-NEXT: retq
;
; EGPR-LABEL: pdep64:
; EGPR: # %bb.0:
; EGPR-NEXT: pdepq %rsi, %rdi, %rax # EVEX TO VEX Compression encoding: [0xc4,0xe2,0xc3,0xf5,0xc6]
; EGPR-NEXT: retq # encoding: [0xc3]
%tmp = tail call i64 @llvm.x86.bmi.pdep.64(i64 %x, i64 %y)
ret i64 %tmp
}
define i64 @pdep64_load(i64 %x, ptr %y) {
; CHECK-LABEL: pdep64_load:
; CHECK: # %bb.0:
; CHECK-NEXT: pdepq (%rsi), %rdi, %rax
; CHECK-NEXT: retq
;
; EGPR-LABEL: pdep64_load:
; EGPR: # %bb.0:
; EGPR-NEXT: pdepq (%rsi), %rdi, %rax # EVEX TO VEX Compression encoding: [0xc4,0xe2,0xc3,0xf5,0x06]
; EGPR-NEXT: retq # encoding: [0xc3]
%y1 = load i64, ptr %y
%tmp = tail call i64 @llvm.x86.bmi.pdep.64(i64 %x, i64 %y1)
ret i64 %tmp
}
define i64 @pdep64_anyext(i32 %x) {
; CHECK-LABEL: pdep64_anyext:
; CHECK: # %bb.0:
; CHECK-NEXT: # kill: def $edi killed $edi def $rdi
; CHECK-NEXT: movabsq $6148914691236517205, %rax # imm = 0x5555555555555555
; CHECK-NEXT: pdepq %rax, %rdi, %rax
; CHECK-NEXT: retq
;
; EGPR-LABEL: pdep64_anyext:
; EGPR: # %bb.0:
; EGPR-NEXT: # kill: def $edi killed $edi def $rdi
; EGPR-NEXT: movabsq $6148914691236517205, %rax # encoding: [0x48,0xb8,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55]
; EGPR-NEXT: # imm = 0x5555555555555555
; EGPR-NEXT: pdepq %rax, %rdi, %rax # EVEX TO VEX Compression encoding: [0xc4,0xe2,0xc3,0xf5,0xc0]
; EGPR-NEXT: retq # encoding: [0xc3]
%x1 = sext i32 %x to i64
%tmp = tail call i64 @llvm.x86.bmi.pdep.64(i64 %x1, i64 6148914691236517205)
ret i64 %tmp
}
declare i64 @llvm.x86.bmi.pdep.64(i64, i64)
define i64 @pext64(i64 %x, i64 %y) {
; CHECK-LABEL: pext64:
; CHECK: # %bb.0:
; CHECK-NEXT: pextq %rsi, %rdi, %rax
; CHECK-NEXT: retq
;
; EGPR-LABEL: pext64:
; EGPR: # %bb.0:
; EGPR-NEXT: pextq %rsi, %rdi, %rax # EVEX TO VEX Compression encoding: [0xc4,0xe2,0xc2,0xf5,0xc6]
; EGPR-NEXT: retq # encoding: [0xc3]
%tmp = tail call i64 @llvm.x86.bmi.pext.64(i64 %x, i64 %y)
ret i64 %tmp
}
define i64 @pext64_load(i64 %x, ptr %y) {
; CHECK-LABEL: pext64_load:
; CHECK: # %bb.0:
; CHECK-NEXT: pextq (%rsi), %rdi, %rax
; CHECK-NEXT: retq
;
; EGPR-LABEL: pext64_load:
; EGPR: # %bb.0:
; EGPR-NEXT: pextq (%rsi), %rdi, %rax # EVEX TO VEX Compression encoding: [0xc4,0xe2,0xc2,0xf5,0x06]
; EGPR-NEXT: retq # encoding: [0xc3]
%y1 = load i64, ptr %y
%tmp = tail call i64 @llvm.x86.bmi.pext.64(i64 %x, i64 %y1)
ret i64 %tmp
}
define i64 @pext64_knownbits(i64 %x, i64 %y) {
; CHECK-LABEL: pext64_knownbits:
; CHECK: # %bb.0:
; CHECK-NEXT: movabsq $6148914691236517205, %rax # imm = 0x5555555555555555
; CHECK-NEXT: pextq %rax, %rdi, %rax
; CHECK-NEXT: retq
;
; EGPR-LABEL: pext64_knownbits:
; EGPR: # %bb.0:
; EGPR-NEXT: movabsq $6148914691236517205, %rax # encoding: [0x48,0xb8,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55]
; EGPR-NEXT: # imm = 0x5555555555555555
; EGPR-NEXT: pextq %rax, %rdi, %rax # EVEX TO VEX Compression encoding: [0xc4,0xe2,0xc2,0xf5,0xc0]
; EGPR-NEXT: retq # encoding: [0xc3]
%tmp = tail call i64 @llvm.x86.bmi.pext.64(i64 %x, i64 6148914691236517205)
%tmp2 = and i64 %tmp, 4294967295
ret i64 %tmp2
}
declare i64 @llvm.x86.bmi.pext.64(i64, i64)
define i64 @mulx64(i64 %x, i64 %y, ptr %p) {
; CHECK-LABEL: mulx64:
; CHECK: # %bb.0:
; CHECK-NEXT: movq %rdx, %rcx
; CHECK-NEXT: movq %rdi, %rdx
; CHECK-NEXT: mulxq %rsi, %rax, %rdx
; CHECK-NEXT: movq %rdx, (%rcx)
; CHECK-NEXT: retq
;
; EGPR-LABEL: mulx64:
; EGPR: # %bb.0:
; EGPR-NEXT: movq %rdx, %rcx # encoding: [0x48,0x89,0xd1]
; EGPR-NEXT: movq %rdi, %rdx # encoding: [0x48,0x89,0xfa]
; EGPR-NEXT: mulxq %rsi, %rax, %rdx # EVEX TO VEX Compression encoding: [0xc4,0xe2,0xfb,0xf6,0xd6]
; EGPR-NEXT: movq %rdx, (%rcx) # encoding: [0x48,0x89,0x11]
; EGPR-NEXT: retq # encoding: [0xc3]
%x1 = zext i64 %x to i128
%y1 = zext i64 %y to i128
%r1 = mul i128 %x1, %y1
%h1 = lshr i128 %r1, 64
%h = trunc i128 %h1 to i64
%l = trunc i128 %r1 to i64
store i64 %h, ptr %p
ret i64 %l
}
define i64 @mulx64_load(i64 %x, ptr %y, ptr %p) {
; CHECK-LABEL: mulx64_load:
; CHECK: # %bb.0:
; CHECK-NEXT: movq %rdx, %rcx
; CHECK-NEXT: movq %rdi, %rdx
; CHECK-NEXT: mulxq (%rsi), %rax, %rdx
; CHECK-NEXT: movq %rdx, (%rcx)
; CHECK-NEXT: retq
;
; EGPR-LABEL: mulx64_load:
; EGPR: # %bb.0:
; EGPR-NEXT: movq %rdx, %rcx # encoding: [0x48,0x89,0xd1]
; EGPR-NEXT: movq %rdi, %rdx # encoding: [0x48,0x89,0xfa]
; EGPR-NEXT: mulxq (%rsi), %rax, %rdx # EVEX TO VEX Compression encoding: [0xc4,0xe2,0xfb,0xf6,0x16]
; EGPR-NEXT: movq %rdx, (%rcx) # encoding: [0x48,0x89,0x11]
; EGPR-NEXT: retq # encoding: [0xc3]
%y1 = load i64, ptr %y
%x2 = zext i64 %x to i128
%y2 = zext i64 %y1 to i128
%r1 = mul i128 %x2, %y2
%h1 = lshr i128 %r1, 64
%h = trunc i128 %h1 to i64
%l = trunc i128 %r1 to i64
store i64 %h, ptr %p
ret i64 %l
}
|