1; RUN: opt -vector-library=LIBMVEC-X86 -passes=inject-tli-mappings,loop-vectorize -S < %s | FileCheck %s 2 3target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" 4target triple = "x86_64-unknown-linux-gnu" 5 6define void @sin_f64(ptr nocapture %varray) { 7; CHECK-LABEL: @sin_f64( 8; CHECK-LABEL: vector.body 9; CHECK: [[TMP5:%.*]] = call <2 x double> @_ZGVbN2v_sin(<2 x double> [[TMP4:%.*]]) 10; 11entry: 12 br label %for.body 13 14for.body: 15 %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ] 16 %tmp = trunc i64 %iv to i32 17 %conv = sitofp i32 %tmp to double 18 %call = tail call double @sin(double %conv) 19 %arrayidx = getelementptr inbounds double, ptr %varray, i64 %iv 20 store double %call, ptr %arrayidx, align 4 21 %iv.next = add nuw nsw i64 %iv, 1 22 %exitcond = icmp eq i64 %iv.next, 1000 23 br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !1 24 25for.end: 26 ret void 27} 28 29!1 = distinct !{!1, !2, !3} 30!2 = !{!"llvm.loop.vectorize.width", i32 2} 31!3 = !{!"llvm.loop.vectorize.enable", i1 true} 32 33 34define void @sin_f32(ptr nocapture %varray) { 35; CHECK-LABEL: @sin_f32( 36; CHECK-LABEL: vector.body 37; CHECK: [[TMP5:%.*]] = call <8 x float> @_ZGVdN8v_sinf(<8 x float> [[TMP4:%.*]]) 38; 39entry: 40 br label %for.body 41 42for.body: 43 %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ] 44 %tmp = trunc i64 %iv to i32 45 %conv = sitofp i32 %tmp to float 46 %call = tail call float @sinf(float %conv) 47 %arrayidx = getelementptr inbounds float, ptr %varray, i64 %iv 48 store float %call, ptr %arrayidx, align 4 49 %iv.next = add nuw nsw i64 %iv, 1 50 %exitcond = icmp eq i64 %iv.next, 1000 51 br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !21 52 53for.end: 54 ret void 55} 56 57!21 = distinct !{!21, !22, !23} 58!22 = !{!"llvm.loop.vectorize.width", i32 8} 59!23 = !{!"llvm.loop.vectorize.enable", i1 true} 60 61define void @sin_f64_intrinsic(ptr nocapture %varray) { 62; CHECK-LABEL: @sin_f64_intrinsic( 63; CHECK-LABEL: vector.body 64; CHECK: [[TMP5:%.*]] = call <2 x double> @_ZGVbN2v_sin(<2 x double> [[TMP4:%.*]]) 65; 66entry: 67 br label %for.body 68 69for.body: 70 %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ] 71 %tmp = trunc i64 %iv to i32 72 %conv = sitofp i32 %tmp to double 73 %call = tail call double @llvm.sin.f64(double %conv) 74 %arrayidx = getelementptr inbounds double, ptr %varray, i64 %iv 75 store double %call, ptr %arrayidx, align 4 76 %iv.next = add nuw nsw i64 %iv, 1 77 %exitcond = icmp eq i64 %iv.next, 1000 78 br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !31 79 80for.end: 81 ret void 82} 83 84!31 = distinct !{!31, !32, !33} 85!32 = !{!"llvm.loop.vectorize.width", i32 2} 86!33 = !{!"llvm.loop.vectorize.enable", i1 true} 87 88define void @sin_f32_intrinsic(ptr nocapture %varray) { 89; CHECK-LABEL: @sin_f32_intrinsic( 90; CHECK-LABEL: vector.body 91; CHECK: [[TMP5:%.*]] = call <8 x float> @_ZGVdN8v_sinf(<8 x float> [[TMP4:%.*]]) 92; 93entry: 94 br label %for.body 95 96for.body: 97 %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ] 98 %tmp = trunc i64 %iv to i32 99 %conv = sitofp i32 %tmp to float 100 %call = tail call float @llvm.sin.f32(float %conv) 101 %arrayidx = getelementptr inbounds float, ptr %varray, i64 %iv 102 store float %call, ptr %arrayidx, align 4 103 %iv.next = add nuw nsw i64 %iv, 1 104 %exitcond = icmp eq i64 %iv.next, 1000 105 br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !41 106 107for.end: 108 ret void 109} 110 111!41 = distinct !{!41, !42, !43} 112!42 = !{!"llvm.loop.vectorize.width", i32 8} 113!43 = !{!"llvm.loop.vectorize.enable", i1 true} 114 115define void @cos_f64(ptr nocapture %varray) { 116; CHECK-LABEL: @cos_f64( 117; CHECK-LABEL: vector.body 118; CHECK: [[TMP5:%.*]] = call <2 x double> @_ZGVbN2v_cos(<2 x double> [[TMP4:%.*]]) 119; 120entry: 121 br label %for.body 122 123for.body: 124 %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ] 125 %tmp = trunc i64 %iv to i32 126 %conv = sitofp i32 %tmp to double 127 %call = tail call double @cos(double %conv) 128 %arrayidx = getelementptr inbounds double, ptr %varray, i64 %iv 129 store double %call, ptr %arrayidx, align 4 130 %iv.next = add nuw nsw i64 %iv, 1 131 %exitcond = icmp eq i64 %iv.next, 1000 132 br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !51 133 134for.end: 135 ret void 136} 137 138!51 = distinct !{!51, !52, !53} 139!52 = !{!"llvm.loop.vectorize.width", i32 2} 140!53 = !{!"llvm.loop.vectorize.enable", i1 true} 141 142define void @cos_f32(ptr nocapture %varray) { 143; CHECK-LABEL: @cos_f32( 144; CHECK-LABEL: vector.body 145; CHECK: [[TMP5:%.*]] = call <8 x float> @_ZGVdN8v_cosf(<8 x float> [[TMP4:%.*]]) 146; 147entry: 148 br label %for.body 149 150for.body: 151 %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ] 152 %tmp = trunc i64 %iv to i32 153 %conv = sitofp i32 %tmp to float 154 %call = tail call float @cosf(float %conv) 155 %arrayidx = getelementptr inbounds float, ptr %varray, i64 %iv 156 store float %call, ptr %arrayidx, align 4 157 %iv.next = add nuw nsw i64 %iv, 1 158 %exitcond = icmp eq i64 %iv.next, 1000 159 br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !61 160 161for.end: 162 ret void 163} 164 165!61 = distinct !{!61, !62, !63} 166!62 = !{!"llvm.loop.vectorize.width", i32 8} 167!63 = !{!"llvm.loop.vectorize.enable", i1 true} 168 169define void @cos_f64_intrinsic(ptr nocapture %varray) { 170; CHECK-LABEL: @cos_f64_intrinsic( 171; CHECK-LABEL: vector.body 172; CHECK: [[TMP5:%.*]] = call <2 x double> @_ZGVbN2v_cos(<2 x double> [[TMP4:%.*]]) 173; 174entry: 175 br label %for.body 176 177for.body: 178 %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ] 179 %tmp = trunc i64 %iv to i32 180 %conv = sitofp i32 %tmp to double 181 %call = tail call double @llvm.cos.f64(double %conv) 182 %arrayidx = getelementptr inbounds double, ptr %varray, i64 %iv 183 store double %call, ptr %arrayidx, align 4 184 %iv.next = add nuw nsw i64 %iv, 1 185 %exitcond = icmp eq i64 %iv.next, 1000 186 br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !71 187 188for.end: 189 ret void 190} 191 192!71 = distinct !{!71, !72, !73} 193!72 = !{!"llvm.loop.vectorize.width", i32 2} 194!73 = !{!"llvm.loop.vectorize.enable", i1 true} 195 196define void @cos_f32_intrinsic(ptr nocapture %varray) { 197; CHECK-LABEL: @cos_f32_intrinsic( 198; CHECK-LABEL: vector.body 199; CHECK: [[TMP5:%.*]] = call <8 x float> @_ZGVdN8v_cosf(<8 x float> [[TMP4:%.*]]) 200; 201entry: 202 br label %for.body 203 204for.body: 205 %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ] 206 %tmp = trunc i64 %iv to i32 207 %conv = sitofp i32 %tmp to float 208 %call = tail call float @llvm.cos.f32(float %conv) 209 %arrayidx = getelementptr inbounds float, ptr %varray, i64 %iv 210 store float %call, ptr %arrayidx, align 4 211 %iv.next = add nuw nsw i64 %iv, 1 212 %exitcond = icmp eq i64 %iv.next, 1000 213 br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !81 214 215for.end: 216 ret void 217} 218 219!81 = distinct !{!81, !82, !83} 220!82 = !{!"llvm.loop.vectorize.width", i32 8} 221!83 = !{!"llvm.loop.vectorize.enable", i1 true} 222 223 224define void @exp_f32(ptr nocapture %varray) { 225; CHECK-LABEL: @exp_f32 226; CHECK-LABEL: vector.body 227; CHECK: <8 x float> @_ZGVdN8v_expf 228entry: 229 br label %for.body 230 231for.body: ; preds = %for.body, %entry 232 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ] 233 %tmp = trunc i64 %indvars.iv to i32 234 %conv = sitofp i32 %tmp to float 235 %call = tail call fast float @expf(float %conv) 236 %arrayidx = getelementptr inbounds float, ptr %varray, i64 %indvars.iv 237 store float %call, ptr %arrayidx, align 4 238 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1 239 %exitcond = icmp eq i64 %indvars.iv.next, 1000 240 br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !91 241 242for.end: ; preds = %for.body 243 ret void 244} 245 246!91 = distinct !{!91, !92, !93} 247!92 = !{!"llvm.loop.vectorize.width", i32 8} 248!93 = !{!"llvm.loop.vectorize.enable", i1 true} 249 250define void @exp_f32_intrin(ptr nocapture %varray) { 251; CHECK-LABEL: @exp_f32_intrin 252; CHECK-LABEL: vector.body 253; CHECK: <8 x float> @_ZGVdN8v_expf 254entry: 255 br label %for.body 256 257for.body: ; preds = %for.body, %entry 258 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ] 259 %tmp = trunc i64 %indvars.iv to i32 260 %conv = sitofp i32 %tmp to float 261 %call = tail call fast float @llvm.exp.f32(float %conv) 262 %arrayidx = getelementptr inbounds float, ptr %varray, i64 %indvars.iv 263 store float %call, ptr %arrayidx, align 4 264 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1 265 %exitcond = icmp eq i64 %indvars.iv.next, 1000 266 br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !101 267 268for.end: ; preds = %for.body 269 ret void 270} 271 272!101 = distinct !{!101, !102, !103} 273!102 = !{!"llvm.loop.vectorize.width", i32 8} 274!103 = !{!"llvm.loop.vectorize.enable", i1 true} 275 276 277define void @log_f32(ptr nocapture %varray) { 278; CHECK-LABEL: @log_f32 279; CHECK-LABEL: vector.body 280; CHECK: <8 x float> @_ZGVdN8v_logf 281entry: 282 br label %for.body 283 284for.body: ; preds = %for.body, %entry 285 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ] 286 %tmp = trunc i64 %indvars.iv to i32 287 %conv = sitofp i32 %tmp to float 288 %call = tail call fast float @logf(float %conv) 289 %arrayidx = getelementptr inbounds float, ptr %varray, i64 %indvars.iv 290 store float %call, ptr %arrayidx, align 4 291 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1 292 %exitcond = icmp eq i64 %indvars.iv.next, 1000 293 br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !111 294 295for.end: ; preds = %for.body 296 ret void 297} 298 299!111 = distinct !{!111, !112, !113} 300!112 = !{!"llvm.loop.vectorize.width", i32 8} 301!113 = !{!"llvm.loop.vectorize.enable", i1 true} 302 303define void @pow_f32(ptr nocapture %varray, ptr nocapture readonly %exp) { 304; CHECK-LABEL: @pow_f32 305; CHECK-LABEL: vector.body 306; CHECK: <8 x float> @_ZGVdN8vv_powf 307entry: 308 br label %for.body 309 310for.body: ; preds = %for.body, %entry 311 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ] 312 %tmp = trunc i64 %indvars.iv to i32 313 %conv = sitofp i32 %tmp to float 314 %arrayidx = getelementptr inbounds float, ptr %exp, i64 %indvars.iv 315 %tmp1 = load float, ptr %arrayidx, align 4 316 %tmp2 = tail call fast float @powf(float %conv, float %tmp1) 317 %arrayidx2 = getelementptr inbounds float, ptr %varray, i64 %indvars.iv 318 store float %tmp2, ptr %arrayidx2, align 4 319 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1 320 %exitcond = icmp eq i64 %indvars.iv.next, 1000 321 br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !121 322 323for.end: ; preds = %for.body 324 ret void 325} 326 327!121 = distinct !{!121, !122, !123} 328!122 = !{!"llvm.loop.vectorize.width", i32 8} 329!123 = !{!"llvm.loop.vectorize.enable", i1 true} 330 331define void @pow_f32_intrin(ptr nocapture %varray, ptr nocapture readonly %exp) { 332; CHECK-LABEL: @pow_f32_intrin 333; CHECK-LABEL: vector.body 334; CHECK: <8 x float> @_ZGVdN8vv_powf 335entry: 336 br label %for.body 337 338for.body: ; preds = %for.body, %entry 339 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ] 340 %tmp = trunc i64 %indvars.iv to i32 341 %conv = sitofp i32 %tmp to float 342 %arrayidx = getelementptr inbounds float, ptr %exp, i64 %indvars.iv 343 %tmp1 = load float, ptr %arrayidx, align 4 344 %tmp2 = tail call fast float @llvm.pow.f32(float %conv, float %tmp1) 345 %arrayidx2 = getelementptr inbounds float, ptr %varray, i64 %indvars.iv 346 store float %tmp2, ptr %arrayidx2, align 4 347 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1 348 %exitcond = icmp eq i64 %indvars.iv.next, 1000 349 br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !131 350 351for.end: ; preds = %for.body 352 ret void 353} 354 355!131 = distinct !{!131, !132, !133} 356!132 = !{!"llvm.loop.vectorize.width", i32 8} 357!133 = !{!"llvm.loop.vectorize.enable", i1 true} 358 359define void @tan_f64(ptr nocapture %varray) { 360; CHECK-LABEL: @tan_f64( 361; CHECK-LABEL: vector.body 362; CHECK: [[TMP5:%.*]] = call <2 x double> @_ZGVbN2v_tan(<2 x double> [[TMP4:%.*]]) 363; 364entry: 365 br label %for.body 366 367for.body: 368 %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ] 369 %tmp = trunc i64 %iv to i32 370 %conv = sitofp i32 %tmp to double 371 %call = tail call double @tan(double %conv) 372 %arrayidx = getelementptr inbounds double, ptr %varray, i64 %iv 373 store double %call, ptr %arrayidx, align 4 374 %iv.next = add nuw nsw i64 %iv, 1 375 %exitcond = icmp eq i64 %iv.next, 1000 376 br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !1 377 378for.end: 379 ret void 380} 381 382!141 = distinct !{!141, !142, !143} 383!142 = !{!"llvm.loop.vectorize.width", i32 2} 384!143 = !{!"llvm.loop.vectorize.enable", i1 true} 385 386 387define void @tan_f32(ptr nocapture %varray) { 388; CHECK-LABEL: @tan_f32( 389; CHECK-LABEL: vector.body 390; CHECK: [[TMP5:%.*]] = call <8 x float> @_ZGVdN8v_tanf(<8 x float> [[TMP4:%.*]]) 391; 392entry: 393 br label %for.body 394 395for.body: 396 %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ] 397 %tmp = trunc i64 %iv to i32 398 %conv = sitofp i32 %tmp to float 399 %call = tail call float @tanf(float %conv) 400 %arrayidx = getelementptr inbounds float, ptr %varray, i64 %iv 401 store float %call, ptr %arrayidx, align 4 402 %iv.next = add nuw nsw i64 %iv, 1 403 %exitcond = icmp eq i64 %iv.next, 1000 404 br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !21 405 406for.end: 407 ret void 408} 409 410!151 = distinct !{!151, !152, !153} 411!152 = !{!"llvm.loop.vectorize.width", i32 8} 412!153 = !{!"llvm.loop.vectorize.enable", i1 true} 413 414define void @tan_f64_intrinsic(ptr nocapture %varray) { 415; CHECK-LABEL: @tan_f64_intrinsic( 416; CHECK-LABEL: vector.body 417; CHECK: [[TMP5:%.*]] = call <2 x double> @_ZGVbN2v_tan(<2 x double> [[TMP4:%.*]]) 418; 419entry: 420 br label %for.body 421 422for.body: 423 %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ] 424 %tmp = trunc i64 %iv to i32 425 %conv = sitofp i32 %tmp to double 426 %call = tail call double @llvm.tan.f64(double %conv) 427 %arrayidx = getelementptr inbounds double, ptr %varray, i64 %iv 428 store double %call, ptr %arrayidx, align 4 429 %iv.next = add nuw nsw i64 %iv, 1 430 %exitcond = icmp eq i64 %iv.next, 1000 431 br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !31 432 433for.end: 434 ret void 435} 436 437!161 = distinct !{!161, !162, !163} 438!162 = !{!"llvm.loop.vectorize.width", i32 2} 439!163 = !{!"llvm.loop.vectorize.enable", i1 true} 440 441define void @tan_f32_intrinsic(ptr nocapture %varray) { 442; CHECK-LABEL: @tan_f32_intrinsic( 443; CHECK-LABEL: vector.body 444; CHECK: [[TMP5:%.*]] = call <8 x float> @_ZGVdN8v_tanf(<8 x float> [[TMP4:%.*]]) 445; 446entry: 447 br label %for.body 448 449for.body: 450 %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ] 451 %tmp = trunc i64 %iv to i32 452 %conv = sitofp i32 %tmp to float 453 %call = tail call float @llvm.tan.f32(float %conv) 454 %arrayidx = getelementptr inbounds float, ptr %varray, i64 %iv 455 store float %call, ptr %arrayidx, align 4 456 %iv.next = add nuw nsw i64 %iv, 1 457 %exitcond = icmp eq i64 %iv.next, 1000 458 br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !41 459 460for.end: 461 ret void 462} 463 464 465 466!171 = distinct !{!171, !172, !173} 467!172 = !{!"llvm.loop.vectorize.width", i32 8} 468!173 = !{!"llvm.loop.vectorize.enable", i1 true} 469 470attributes #0 = { nounwind readnone } 471 472declare double @sin(double) #0 473declare float @sinf(float) #0 474declare double @llvm.sin.f64(double) #0 475declare float @llvm.sin.f32(float) #0 476declare double @cos(double) #0 477declare float @cosf(float) #0 478declare double @llvm.cos.f64(double) #0 479declare float @llvm.cos.f32(float) #0 480declare double @tan(double) #0 481declare float @tanf(float) #0 482declare double @llvm.tan.f64(double) #0 483declare float @llvm.tan.f32(float) #0 484declare float @expf(float) #0 485declare float @powf(float, float) #0 486declare float @llvm.exp.f32(float) #0 487declare float @logf(float) #0 488declare float @llvm.pow.f32(float, float) #0 489