1 ; RUN: llc < %s -march=x86-64 -mattr=+bmi,+bmi2 | FileCheck %s 2 3 declare i8 @llvm.cttz.i8(i8, i1) nounwind readnone 4 declare i16 @llvm.cttz.i16(i16, i1) nounwind readnone 5 declare i32 @llvm.cttz.i32(i32, i1) nounwind readnone 6 declare i64 @llvm.cttz.i64(i64, i1) nounwind readnone 7 8 define i8 @t1(i8 %x) nounwind { 9 %tmp = tail call i8 @llvm.cttz.i8( i8 %x, i1 false ) 10 ret i8 %tmp 11 ; CHECK: t1: 12 ; CHECK: tzcntl 13 } 14 15 define i16 @t2(i16 %x) nounwind { 16 %tmp = tail call i16 @llvm.cttz.i16( i16 %x, i1 false ) 17 ret i16 %tmp 18 ; CHECK: t2: 19 ; CHECK: tzcntw 20 } 21 22 define i32 @t3(i32 %x) nounwind { 23 %tmp = tail call i32 @llvm.cttz.i32( i32 %x, i1 false ) 24 ret i32 %tmp 25 ; CHECK: t3: 26 ; CHECK: tzcntl 27 } 28 29 define i64 @t4(i64 %x) nounwind { 30 %tmp = tail call i64 @llvm.cttz.i64( i64 %x, i1 false ) 31 ret i64 %tmp 32 ; CHECK: t4: 33 ; CHECK: tzcntq 34 } 35 36 define i8 @t5(i8 %x) nounwind { 37 %tmp = tail call i8 @llvm.cttz.i8( i8 %x, i1 true ) 38 ret i8 %tmp 39 ; CHECK: t5: 40 ; CHECK: tzcntl 41 } 42 43 define i16 @t6(i16 %x) nounwind { 44 %tmp = tail call i16 @llvm.cttz.i16( i16 %x, i1 true ) 45 ret i16 %tmp 46 ; CHECK: t6: 47 ; CHECK: tzcntw 48 } 49 50 define i32 @t7(i32 %x) nounwind { 51 %tmp = tail call i32 @llvm.cttz.i32( i32 %x, i1 true ) 52 ret i32 %tmp 53 ; CHECK: t7: 54 ; CHECK: tzcntl 55 } 56 57 define i64 @t8(i64 %x) nounwind { 58 %tmp = tail call i64 @llvm.cttz.i64( i64 %x, i1 true ) 59 ret i64 %tmp 60 ; CHECK: t8: 61 ; CHECK: tzcntq 62 } 63 64 define i32 @andn32(i32 %x, i32 %y) nounwind readnone { 65 %tmp1 = xor i32 %x, -1 66 %tmp2 = and i32 %y, %tmp1 67 ret i32 %tmp2 68 ; CHECK: andn32: 69 ; CHECK: andnl 70 } 71 72 define i64 @andn64(i64 %x, i64 %y) nounwind readnone { 73 %tmp1 = xor i64 %x, -1 74 %tmp2 = and i64 %tmp1, %y 75 ret i64 %tmp2 76 ; CHECK: andn64: 77 ; CHECK: andnq 78 } 79 80 define i32 @bextr32(i32 %x, i32 %y) nounwind readnone { 81 %tmp = tail call i32 @llvm.x86.bmi.bextr.32(i32 %x, i32 %y) 82 ret i32 %tmp 83 ; CHECK: bextr32: 84 ; CHECK: bextrl 85 } 86 87 declare i32 @llvm.x86.bmi.bextr.32(i32, i32) nounwind readnone 88 89 define i64 @bextr64(i64 %x, i64 %y) nounwind readnone { 90 %tmp = tail call i64 @llvm.x86.bmi.bextr.64(i64 %x, i64 %y) 91 ret i64 %tmp 92 ; CHECK: bextr64: 93 ; CHECK: bextrq 94 } 95 96 declare i64 @llvm.x86.bmi.bextr.64(i64, i64) nounwind readnone 97 98 define i32 @bzhi32(i32 %x, i32 %y) nounwind readnone { 99 %tmp = tail call i32 @llvm.x86.bmi.bzhi.32(i32 %x, i32 %y) 100 ret i32 %tmp 101 ; CHECK: bzhi32: 102 ; CHECK: bzhil 103 } 104 105 declare i32 @llvm.x86.bmi.bzhi.32(i32, i32) nounwind readnone 106 107 define i64 @bzhi64(i64 %x, i64 %y) nounwind readnone { 108 %tmp = tail call i64 @llvm.x86.bmi.bzhi.64(i64 %x, i64 %y) 109 ret i64 %tmp 110 ; CHECK: bzhi64: 111 ; CHECK: bzhiq 112 } 113 114 declare i64 @llvm.x86.bmi.bzhi.64(i64, i64) nounwind readnone 115 116 define i32 @blsi32(i32 %x) nounwind readnone { 117 %tmp = sub i32 0, %x 118 %tmp2 = and i32 %x, %tmp 119 ret i32 %tmp2 120 ; CHECK: blsi32: 121 ; CHECK: blsil 122 } 123 124 define i64 @blsi64(i64 %x) nounwind readnone { 125 %tmp = sub i64 0, %x 126 %tmp2 = and i64 %tmp, %x 127 ret i64 %tmp2 128 ; CHECK: blsi64: 129 ; CHECK: blsiq 130 } 131 132 define i32 @blsmsk32(i32 %x) nounwind readnone { 133 %tmp = sub i32 %x, 1 134 %tmp2 = xor i32 %x, %tmp 135 ret i32 %tmp2 136 ; CHECK: blsmsk32: 137 ; CHECK: blsmskl 138 } 139 140 define i64 @blsmsk64(i64 %x) nounwind readnone { 141 %tmp = sub i64 %x, 1 142 %tmp2 = xor i64 %tmp, %x 143 ret i64 %tmp2 144 ; CHECK: blsmsk64: 145 ; CHECK: blsmskq 146 } 147 148 define i32 @blsr32(i32 %x) nounwind readnone { 149 %tmp = sub i32 %x, 1 150 %tmp2 = and i32 %x, %tmp 151 ret i32 %tmp2 152 ; CHECK: blsr32: 153 ; CHECK: blsrl 154 } 155 156 define i64 @blsr64(i64 %x) nounwind readnone { 157 %tmp = sub i64 %x, 1 158 %tmp2 = and i64 %tmp, %x 159 ret i64 %tmp2 160 ; CHECK: blsr64: 161 ; CHECK: blsrq 162 } 163 164 define i32 @pdep32(i32 %x, i32 %y) nounwind readnone { 165 %tmp = tail call i32 @llvm.x86.bmi.pdep.32(i32 %x, i32 %y) 166 ret i32 %tmp 167 ; CHECK: pdep32: 168 ; CHECK: pdepl 169 } 170 171 declare i32 @llvm.x86.bmi.pdep.32(i32, i32) nounwind readnone 172 173 define i64 @pdep64(i64 %x, i64 %y) nounwind readnone { 174 %tmp = tail call i64 @llvm.x86.bmi.pdep.64(i64 %x, i64 %y) 175 ret i64 %tmp 176 ; CHECK: pdep64: 177 ; CHECK: pdepq 178 } 179 180 declare i64 @llvm.x86.bmi.pdep.64(i64, i64) nounwind readnone 181 182 define i32 @pext32(i32 %x, i32 %y) nounwind readnone { 183 %tmp = tail call i32 @llvm.x86.bmi.pext.32(i32 %x, i32 %y) 184 ret i32 %tmp 185 ; CHECK: pext32: 186 ; CHECK: pextl 187 } 188 189 declare i32 @llvm.x86.bmi.pext.32(i32, i32) nounwind readnone 190 191 define i64 @pext64(i64 %x, i64 %y) nounwind readnone { 192 %tmp = tail call i64 @llvm.x86.bmi.pext.64(i64 %x, i64 %y) 193 ret i64 %tmp 194 ; CHECK: pext64: 195 ; CHECK: pextq 196 } 197 198 declare i64 @llvm.x86.bmi.pext.64(i64, i64) nounwind readnone 199 200