1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+bmi,+bmi2 | FileCheck %s --check-prefixes=CHECK
4 define i64 @bzhi64(i64 %x, i64 %y) {
7 ; CHECK-NEXT: bzhiq %rsi, %rdi, %rax
9 %tmp = tail call i64 @llvm.x86.bmi.bzhi.64(i64 %x, i64 %y)
13 define i64 @bzhi64_load(ptr %x, i64 %y) {
14 ; CHECK-LABEL: bzhi64_load:
16 ; CHECK-NEXT: bzhiq %rsi, (%rdi), %rax
18 %x1 = load i64, ptr %x
19 %tmp = tail call i64 @llvm.x86.bmi.bzhi.64(i64 %x1, i64 %y)
23 declare i64 @llvm.x86.bmi.bzhi.64(i64, i64)
25 define i64 @pdep64(i64 %x, i64 %y) {
26 ; CHECK-LABEL: pdep64:
28 ; CHECK-NEXT: pdepq %rsi, %rdi, %rax
30 %tmp = tail call i64 @llvm.x86.bmi.pdep.64(i64 %x, i64 %y)
34 define i64 @pdep64_load(i64 %x, ptr %y) {
35 ; CHECK-LABEL: pdep64_load:
37 ; CHECK-NEXT: pdepq (%rsi), %rdi, %rax
39 %y1 = load i64, ptr %y
40 %tmp = tail call i64 @llvm.x86.bmi.pdep.64(i64 %x, i64 %y1)
44 define i64 @pdep64_anyext(i32 %x) {
45 ; CHECK-LABEL: pdep64_anyext:
47 ; CHECK-NEXT: # kill: def $edi killed $edi def $rdi
48 ; CHECK-NEXT: movabsq $6148914691236517205, %rax # imm = 0x5555555555555555
49 ; CHECK-NEXT: pdepq %rax, %rdi, %rax
51 %x1 = sext i32 %x to i64
52 %tmp = tail call i64 @llvm.x86.bmi.pdep.64(i64 %x1, i64 6148914691236517205)
56 declare i64 @llvm.x86.bmi.pdep.64(i64, i64)
58 define i64 @pext64(i64 %x, i64 %y) {
59 ; CHECK-LABEL: pext64:
61 ; CHECK-NEXT: pextq %rsi, %rdi, %rax
63 %tmp = tail call i64 @llvm.x86.bmi.pext.64(i64 %x, i64 %y)
67 define i64 @pext64_load(i64 %x, ptr %y) {
68 ; CHECK-LABEL: pext64_load:
70 ; CHECK-NEXT: pextq (%rsi), %rdi, %rax
72 %y1 = load i64, ptr %y
73 %tmp = tail call i64 @llvm.x86.bmi.pext.64(i64 %x, i64 %y1)
77 define i64 @pext64_knownbits(i64 %x, i64 %y) {
78 ; CHECK-LABEL: pext64_knownbits:
80 ; CHECK-NEXT: movabsq $6148914691236517205, %rax # imm = 0x5555555555555555
81 ; CHECK-NEXT: pextq %rax, %rdi, %rax
83 %tmp = tail call i64 @llvm.x86.bmi.pext.64(i64 %x, i64 6148914691236517205)
84 %tmp2 = and i64 %tmp, 4294967295
88 declare i64 @llvm.x86.bmi.pext.64(i64, i64)
90 define i64 @mulx64(i64 %x, i64 %y, ptr %p) {
91 ; CHECK-LABEL: mulx64:
93 ; CHECK-NEXT: movq %rdx, %rcx
94 ; CHECK-NEXT: movq %rdi, %rdx
95 ; CHECK-NEXT: mulxq %rsi, %rax, %rdx
96 ; CHECK-NEXT: movq %rdx, (%rcx)
98 %x1 = zext i64 %x to i128
99 %y1 = zext i64 %y to i128
100 %r1 = mul i128 %x1, %y1
101 %h1 = lshr i128 %r1, 64
102 %h = trunc i128 %h1 to i64
103 %l = trunc i128 %r1 to i64
108 define i64 @mulx64_load(i64 %x, ptr %y, ptr %p) {
109 ; CHECK-LABEL: mulx64_load:
111 ; CHECK-NEXT: movq %rdx, %rcx
112 ; CHECK-NEXT: movq %rdi, %rdx
113 ; CHECK-NEXT: mulxq (%rsi), %rax, %rdx
114 ; CHECK-NEXT: movq %rdx, (%rcx)
116 %y1 = load i64, ptr %y
117 %x2 = zext i64 %x to i128
118 %y2 = zext i64 %y1 to i128
119 %r1 = mul i128 %x2, %y2
120 %h1 = lshr i128 %r1, 64
121 %h = trunc i128 %h1 to i64
122 %l = trunc i128 %r1 to i64