1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 2 3; RUN: opt < %s -passes=loop-vectorize -force-vector-width=4 -force-vector-interleave=1 -S | FileCheck %s 4 5define void @select_with_fastmath_flags(ptr noalias %a, ptr noalias %b, ptr noalias %c, i64 %N) { 6; CHECK-LABEL: define void @select_with_fastmath_flags( 7; CHECK-SAME: ptr noalias [[A:%.*]], ptr noalias [[B:%.*]], ptr noalias [[C:%.*]], i64 [[N:%.*]]) { 8; CHECK-NEXT: [[ENTRY:.*]]: 9; CHECK-NEXT: [[MIN_ITERS_CHECK:%.*]] = icmp ult i64 [[N]], 4 10; CHECK-NEXT: br i1 [[MIN_ITERS_CHECK]], label %[[SCALAR_PH:.*]], label %[[VECTOR_PH:.*]] 11; CHECK: [[VECTOR_PH]]: 12; CHECK-NEXT: [[N_MOD_VF:%.*]] = urem i64 [[N]], 4 13; CHECK-NEXT: [[N_VEC:%.*]] = sub i64 [[N]], [[N_MOD_VF]] 14; CHECK-NEXT: br label %[[VECTOR_BODY:.*]] 15; CHECK: [[VECTOR_BODY]]: 16; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, %[[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], %[[VECTOR_BODY]] ] 17; CHECK-NEXT: [[TMP0:%.*]] = add i64 [[INDEX]], 0 18; CHECK-NEXT: [[TMP1:%.*]] = getelementptr inbounds nuw float, ptr [[B]], i64 [[TMP0]] 19; CHECK-NEXT: [[TMP2:%.*]] = getelementptr inbounds nuw float, ptr [[TMP1]], i32 0 20; CHECK-NEXT: [[WIDE_LOAD:%.*]] = load <4 x float>, ptr [[TMP2]], align 4 21; CHECK-NEXT: [[TMP3:%.*]] = getelementptr inbounds nuw float, ptr [[C]], i64 [[TMP0]] 22; CHECK-NEXT: [[TMP4:%.*]] = getelementptr inbounds nuw float, ptr [[TMP3]], i32 0 23; CHECK-NEXT: [[WIDE_LOAD1:%.*]] = load <4 x float>, ptr [[TMP4]], align 4 24; CHECK-NEXT: [[TMP5:%.*]] = fcmp fast ogt <4 x float> [[WIDE_LOAD]], [[WIDE_LOAD1]] 25; CHECK-NEXT: [[TMP6:%.*]] = fadd fast <4 x float> [[WIDE_LOAD]], splat (float 1.000000e+01) 26; CHECK-NEXT: [[TMP7:%.*]] = select fast <4 x i1> [[TMP5]], <4 x float> [[TMP6]], <4 x float> [[WIDE_LOAD1]] 27; CHECK-NEXT: [[TMP8:%.*]] = getelementptr inbounds nuw float, ptr [[A]], i64 [[TMP0]] 28; CHECK-NEXT: [[TMP9:%.*]] = getelementptr inbounds nuw float, ptr [[TMP8]], i32 0 29; CHECK-NEXT: store <4 x float> [[TMP7]], ptr [[TMP9]], align 4 30; CHECK-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 4 31; CHECK-NEXT: [[TMP10:%.*]] = icmp eq i64 [[INDEX_NEXT]], [[N_VEC]] 32; CHECK-NEXT: br i1 [[TMP10]], label %[[MIDDLE_BLOCK:.*]], label %[[VECTOR_BODY]], !llvm.loop [[LOOP0:![0-9]+]] 33; CHECK: [[MIDDLE_BLOCK]]: 34; CHECK-NEXT: [[CMP_N:%.*]] = icmp eq i64 [[N]], [[N_VEC]] 35; CHECK-NEXT: br i1 [[CMP_N]], label %[[EXIT:.*]], label %[[SCALAR_PH]] 36; CHECK: [[SCALAR_PH]]: 37; CHECK-NEXT: [[BC_RESUME_VAL:%.*]] = phi i64 [ [[N_VEC]], %[[MIDDLE_BLOCK]] ], [ 0, %[[ENTRY]] ] 38; CHECK-NEXT: br label %[[FOR_BODY:.*]] 39; CHECK: [[FOR_BODY]]: 40; CHECK-NEXT: [[IV:%.*]] = phi i64 [ [[IV_NEXT:%.*]], %[[FOR_BODY]] ], [ [[BC_RESUME_VAL]], %[[SCALAR_PH]] ] 41; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds nuw float, ptr [[B]], i64 [[IV]] 42; CHECK-NEXT: [[TMP11:%.*]] = load float, ptr [[GEP]], align 4 43; CHECK-NEXT: [[GEP3:%.*]] = getelementptr inbounds nuw float, ptr [[C]], i64 [[IV]] 44; CHECK-NEXT: [[TMP12:%.*]] = load float, ptr [[GEP3]], align 4 45; CHECK-NEXT: [[CMP4:%.*]] = fcmp fast ogt float [[TMP11]], [[TMP12]] 46; CHECK-NEXT: [[ADD:%.*]] = fadd fast float [[TMP11]], 1.000000e+01 47; CHECK-NEXT: [[COND:%.*]] = select fast i1 [[CMP4]], float [[ADD]], float [[TMP12]] 48; CHECK-NEXT: [[GEP11:%.*]] = getelementptr inbounds nuw float, ptr [[A]], i64 [[IV]] 49; CHECK-NEXT: store float [[COND]], ptr [[GEP11]], align 4 50; CHECK-NEXT: [[IV_NEXT]] = add nuw nsw i64 [[IV]], 1 51; CHECK-NEXT: [[EXITCOND_NOT:%.*]] = icmp eq i64 [[IV_NEXT]], [[N]] 52; CHECK-NEXT: br i1 [[EXITCOND_NOT]], label %[[EXIT]], label %[[FOR_BODY]], !llvm.loop [[LOOP3:![0-9]+]] 53; CHECK: [[EXIT]]: 54; CHECK-NEXT: ret void 55; 56entry: 57 br label %for.body 58 59for.body: 60 %iv = phi i64 [ %iv.next, %for.body ], [ 0, %entry ] 61 %gep = getelementptr inbounds nuw float, ptr %b, i64 %iv 62 %0 = load float, ptr %gep, align 4 63 %gep3 = getelementptr inbounds nuw float, ptr %c, i64 %iv 64 %1 = load float, ptr %gep3, align 4 65 %cmp4 = fcmp fast ogt float %0, %1 66 %add = fadd fast float %0, 1.000000e+01 67 %cond = select fast i1 %cmp4, float %add, float %1 68 %gep11 = getelementptr inbounds nuw float, ptr %a, i64 %iv 69 store float %cond, ptr %gep11, align 4 70 %iv.next = add nuw nsw i64 %iv, 1 71 %exitcond.not = icmp eq i64 %iv.next, %N 72 br i1 %exitcond.not, label %exit, label %for.body 73 74exit: 75 ret void 76} 77 78; CHECK: [[LOOP0]] = distinct !{[[LOOP0]], [[META1:![0-9]+]], [[META2:![0-9]+]]} 79; CHECK: [[META1]] = !{!"llvm.loop.isvectorized", i32 1} 80; CHECK: [[META2]] = !{!"llvm.loop.unroll.runtime.disable"} 81; CHECK: [[LOOP3]] = distinct !{[[LOOP3]], [[META2]], [[META1]]} 82;. 83