1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 2 ; RUN: llc < %s -disable-peephole -mtriple=x86_64-apple-macosx -mattr=+sse4.1 | FileCheck -check-prefix=CHECK-SSE %s 3 ; RUN: llc < %s -disable-peephole -mtriple=x86_64-apple-macosx -mattr=+avx | FileCheck -check-prefix=CHECK-AVX %s 4 ; RUN: llc < %s -disable-peephole -mtriple=x86_64-apple-macosx -mattr=+avx512f | FileCheck -check-prefix=CHECK-AVX512 %s 5 6 define float @test1(float %x) nounwind { 7 ; CHECK-SSE-LABEL: test1: 8 ; CHECK-SSE: ## %bb.0: 9 ; CHECK-SSE-NEXT: roundss $9, %xmm0, %xmm0 10 ; CHECK-SSE-NEXT: retq 11 ; 12 ; CHECK-AVX-LABEL: test1: 13 ; CHECK-AVX: ## %bb.0: 14 ; CHECK-AVX-NEXT: vroundss $9, %xmm0, %xmm0, %xmm0 15 ; CHECK-AVX-NEXT: retq 16 ; 17 ; CHECK-AVX512-LABEL: test1: 18 ; CHECK-AVX512: ## %bb.0: 19 ; CHECK-AVX512-NEXT: vroundss $9, %xmm0, %xmm0, %xmm0 20 ; CHECK-AVX512-NEXT: retq 21 %call = tail call float @floorf(float %x) nounwind readnone 22 ret float %call 23 } 24 25 declare float @floorf(float) nounwind readnone 26 27 define double @test2(double %x) nounwind { 28 ; CHECK-SSE-LABEL: test2: 29 ; CHECK-SSE: ## %bb.0: 30 ; CHECK-SSE-NEXT: roundsd $9, %xmm0, %xmm0 31 ; CHECK-SSE-NEXT: retq 32 ; 33 ; CHECK-AVX-LABEL: test2: 34 ; CHECK-AVX: ## %bb.0: 35 ; CHECK-AVX-NEXT: vroundsd $9, %xmm0, %xmm0, %xmm0 36 ; CHECK-AVX-NEXT: retq 37 ; 38 ; CHECK-AVX512-LABEL: test2: 39 ; CHECK-AVX512: ## %bb.0: 40 ; CHECK-AVX512-NEXT: vroundsd $9, %xmm0, %xmm0, %xmm0 41 ; CHECK-AVX512-NEXT: retq 42 %call = tail call double @floor(double %x) nounwind readnone 43 ret double %call 44 } 45 46 declare double @floor(double) nounwind readnone 47 48 define float @test3(float %x) nounwind { 49 ; CHECK-SSE-LABEL: test3: 50 ; CHECK-SSE: ## %bb.0: 51 ; CHECK-SSE-NEXT: roundss $12, %xmm0, %xmm0 52 ; CHECK-SSE-NEXT: retq 53 ; 54 ; CHECK-AVX-LABEL: test3: 55 ; CHECK-AVX: ## %bb.0: 56 ; CHECK-AVX-NEXT: vroundss $12, %xmm0, %xmm0, %xmm0 57 ; CHECK-AVX-NEXT: retq 58 ; 59 ; CHECK-AVX512-LABEL: test3: 60 ; CHECK-AVX512: ## %bb.0: 61 ; CHECK-AVX512-NEXT: vroundss $12, %xmm0, %xmm0, %xmm0 62 ; CHECK-AVX512-NEXT: retq 63 %call = tail call float @nearbyintf(float %x) nounwind readnone 64 ret float %call 65 } 66 67 declare float @nearbyintf(float) nounwind readnone 68 69 define double @test4(double %x) nounwind { 70 ; CHECK-SSE-LABEL: test4: 71 ; CHECK-SSE: ## %bb.0: 72 ; CHECK-SSE-NEXT: roundsd $12, %xmm0, %xmm0 73 ; CHECK-SSE-NEXT: retq 74 ; 75 ; CHECK-AVX-LABEL: test4: 76 ; CHECK-AVX: ## %bb.0: 77 ; CHECK-AVX-NEXT: vroundsd $12, %xmm0, %xmm0, %xmm0 78 ; CHECK-AVX-NEXT: retq 79 ; 80 ; CHECK-AVX512-LABEL: test4: 81 ; CHECK-AVX512: ## %bb.0: 82 ; CHECK-AVX512-NEXT: vroundsd $12, %xmm0, %xmm0, %xmm0 83 ; CHECK-AVX512-NEXT: retq 84 %call = tail call double @nearbyint(double %x) nounwind readnone 85 ret double %call 86 } 87 88 declare double @nearbyint(double) nounwind readnone 89 90 define float @test5(float %x) nounwind { 91 ; CHECK-SSE-LABEL: test5: 92 ; CHECK-SSE: ## %bb.0: 93 ; CHECK-SSE-NEXT: roundss $10, %xmm0, %xmm0 94 ; CHECK-SSE-NEXT: retq 95 ; 96 ; CHECK-AVX-LABEL: test5: 97 ; CHECK-AVX: ## %bb.0: 98 ; CHECK-AVX-NEXT: vroundss $10, %xmm0, %xmm0, %xmm0 99 ; CHECK-AVX-NEXT: retq 100 ; 101 ; CHECK-AVX512-LABEL: test5: 102 ; CHECK-AVX512: ## %bb.0: 103 ; CHECK-AVX512-NEXT: vroundss $10, %xmm0, %xmm0, %xmm0 104 ; CHECK-AVX512-NEXT: retq 105 %call = tail call float @ceilf(float %x) nounwind readnone 106 ret float %call 107 } 108 109 declare float @ceilf(float) nounwind readnone 110 111 define double @test6(double %x) nounwind { 112 ; CHECK-SSE-LABEL: test6: 113 ; CHECK-SSE: ## %bb.0: 114 ; CHECK-SSE-NEXT: roundsd $10, %xmm0, %xmm0 115 ; CHECK-SSE-NEXT: retq 116 ; 117 ; CHECK-AVX-LABEL: test6: 118 ; CHECK-AVX: ## %bb.0: 119 ; CHECK-AVX-NEXT: vroundsd $10, %xmm0, %xmm0, %xmm0 120 ; CHECK-AVX-NEXT: retq 121 ; 122 ; CHECK-AVX512-LABEL: test6: 123 ; CHECK-AVX512: ## %bb.0: 124 ; CHECK-AVX512-NEXT: vroundsd $10, %xmm0, %xmm0, %xmm0 125 ; CHECK-AVX512-NEXT: retq 126 %call = tail call double @ceil(double %x) nounwind readnone 127 ret double %call 128 } 129 130 declare double @ceil(double) nounwind readnone 131 132 define float @test7(float %x) nounwind { 133 ; CHECK-SSE-LABEL: test7: 134 ; CHECK-SSE: ## %bb.0: 135 ; CHECK-SSE-NEXT: roundss $4, %xmm0, %xmm0 136 ; CHECK-SSE-NEXT: retq 137 ; 138 ; CHECK-AVX-LABEL: test7: 139 ; CHECK-AVX: ## %bb.0: 140 ; CHECK-AVX-NEXT: vroundss $4, %xmm0, %xmm0, %xmm0 141 ; CHECK-AVX-NEXT: retq 142 ; 143 ; CHECK-AVX512-LABEL: test7: 144 ; CHECK-AVX512: ## %bb.0: 145 ; CHECK-AVX512-NEXT: vroundss $4, %xmm0, %xmm0, %xmm0 146 ; CHECK-AVX512-NEXT: retq 147 %call = tail call float @rintf(float %x) nounwind readnone 148 ret float %call 149 } 150 151 declare float @rintf(float) nounwind readnone 152 153 define double @test8(double %x) nounwind { 154 ; CHECK-SSE-LABEL: test8: 155 ; CHECK-SSE: ## %bb.0: 156 ; CHECK-SSE-NEXT: roundsd $4, %xmm0, %xmm0 157 ; CHECK-SSE-NEXT: retq 158 ; 159 ; CHECK-AVX-LABEL: test8: 160 ; CHECK-AVX: ## %bb.0: 161 ; CHECK-AVX-NEXT: vroundsd $4, %xmm0, %xmm0, %xmm0 162 ; CHECK-AVX-NEXT: retq 163 ; 164 ; CHECK-AVX512-LABEL: test8: 165 ; CHECK-AVX512: ## %bb.0: 166 ; CHECK-AVX512-NEXT: vroundsd $4, %xmm0, %xmm0, %xmm0 167 ; CHECK-AVX512-NEXT: retq 168 %call = tail call double @rint(double %x) nounwind readnone 169 ret double %call 170 } 171 172 declare double @rint(double) nounwind readnone 173 174 define float @test9(float %x) nounwind { 175 ; CHECK-SSE-LABEL: test9: 176 ; CHECK-SSE: ## %bb.0: 177 ; CHECK-SSE-NEXT: roundss $11, %xmm0, %xmm0 178 ; CHECK-SSE-NEXT: retq 179 ; 180 ; CHECK-AVX-LABEL: test9: 181 ; CHECK-AVX: ## %bb.0: 182 ; CHECK-AVX-NEXT: vroundss $11, %xmm0, %xmm0, %xmm0 183 ; CHECK-AVX-NEXT: retq 184 ; 185 ; CHECK-AVX512-LABEL: test9: 186 ; CHECK-AVX512: ## %bb.0: 187 ; CHECK-AVX512-NEXT: vroundss $11, %xmm0, %xmm0, %xmm0 188 ; CHECK-AVX512-NEXT: retq 189 %call = tail call float @truncf(float %x) nounwind readnone 190 ret float %call 191 } 192 193 declare float @truncf(float) nounwind readnone 194 195 define double @test10(double %x) nounwind { 196 ; CHECK-SSE-LABEL: test10: 197 ; CHECK-SSE: ## %bb.0: 198 ; CHECK-SSE-NEXT: roundsd $11, %xmm0, %xmm0 199 ; CHECK-SSE-NEXT: retq 200 ; 201 ; CHECK-AVX-LABEL: test10: 202 ; CHECK-AVX: ## %bb.0: 203 ; CHECK-AVX-NEXT: vroundsd $11, %xmm0, %xmm0, %xmm0 204 ; CHECK-AVX-NEXT: retq 205 ; 206 ; CHECK-AVX512-LABEL: test10: 207 ; CHECK-AVX512: ## %bb.0: 208 ; CHECK-AVX512-NEXT: vroundsd $11, %xmm0, %xmm0, %xmm0 209 ; CHECK-AVX512-NEXT: retq 210 %call = tail call double @trunc(double %x) nounwind readnone 211 ret double %call 212 } 213 214 declare double @trunc(double) nounwind readnone 215 216 define float @test11(float* %xptr) nounwind optsize { 217 ; CHECK-SSE-LABEL: test11: 218 ; CHECK-SSE: ## %bb.0: 219 ; CHECK-SSE-NEXT: roundss $11, (%rdi), %xmm0 220 ; CHECK-SSE-NEXT: retq 221 ; 222 ; CHECK-AVX-LABEL: test11: 223 ; CHECK-AVX: ## %bb.0: 224 ; CHECK-AVX-NEXT: vroundss $11, (%rdi), %xmm0, %xmm0 225 ; CHECK-AVX-NEXT: retq 226 ; 227 ; CHECK-AVX512-LABEL: test11: 228 ; CHECK-AVX512: ## %bb.0: 229 ; CHECK-AVX512-NEXT: vroundss $11, (%rdi), %xmm0, %xmm0 230 ; CHECK-AVX512-NEXT: retq 231 %x = load float, float* %xptr 232 %call = tail call float @truncf(float %x) nounwind readnone 233 ret float %call 234 } 235 236 define double @test12(double* %xptr) nounwind optsize { 237 ; CHECK-SSE-LABEL: test12: 238 ; CHECK-SSE: ## %bb.0: 239 ; CHECK-SSE-NEXT: roundsd $11, (%rdi), %xmm0 240 ; CHECK-SSE-NEXT: retq 241 ; 242 ; CHECK-AVX-LABEL: test12: 243 ; CHECK-AVX: ## %bb.0: 244 ; CHECK-AVX-NEXT: vroundsd $11, (%rdi), %xmm0, %xmm0 245 ; CHECK-AVX-NEXT: retq 246 ; 247 ; CHECK-AVX512-LABEL: test12: 248 ; CHECK-AVX512: ## %bb.0: 249 ; CHECK-AVX512-NEXT: vroundsd $11, (%rdi), %xmm0, %xmm0 250 ; CHECK-AVX512-NEXT: retq 251 %x = load double, double* %xptr 252 %call = tail call double @trunc(double %x) nounwind readnone 253 ret double %call 254 } 255