Index: lib/Analysis/VectorUtils.cpp =================================================================== --- lib/Analysis/VectorUtils.cpp +++ lib/Analysis/VectorUtils.cpp @@ -54,6 +54,8 @@ case Intrinsic::fabs: case Intrinsic::minnum: case Intrinsic::maxnum: + case Intrinsic::minnan: + case Intrinsic::maxnan: case Intrinsic::copysign: case Intrinsic::floor: case Intrinsic::ceil: Index: test/Transforms/LoopVectorize/intrinsic.ll =================================================================== --- test/Transforms/LoopVectorize/intrinsic.ll +++ test/Transforms/LoopVectorize/intrinsic.ll @@ -1247,3 +1247,59 @@ for.end: ; preds = %for.body, %entry ret void } + +declare float @llvm.minnan.f32(float, float) nounwind readnone + +;CHECK-LABEL: @minnan_f32( +;CHECK: llvm.minnan.v4f32 +;CHECK: ret void +define void @minnan_f32(i32 %n, float* noalias %y, float* noalias %x, float* noalias %z) nounwind uwtable { +entry: + %cmp9 = icmp sgt i32 %n, 0 + br i1 %cmp9, label %for.body, label %for.end + +for.body: ; preds = %entry, %for.body + %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ] + %arrayidx = getelementptr inbounds float, float* %y, i64 %indvars.iv + %0 = load float, float* %arrayidx, align 4 + %arrayidx2 = getelementptr inbounds float, float* %z, i64 %indvars.iv + %1 = load float, float* %arrayidx2, align 4 + %call = tail call float @llvm.minnan.f32(float %0, float %1) nounwind readnone + %arrayidx4 = getelementptr inbounds float, float* %x, i64 %indvars.iv + store float %call, float* %arrayidx4, align 4 + %indvars.iv.next = add i64 %indvars.iv, 1 + %lftr.wideiv = trunc i64 %indvars.iv.next to i32 + %exitcond = icmp eq i32 %lftr.wideiv, %n + br i1 %exitcond, label %for.end, label %for.body + +for.end: ; preds = %for.body, %entry + ret void +} + +declare float @llvm.maxnan.f32(float, float) nounwind readnone + +;CHECK-LABEL: @maxnan_f32( +;CHECK: llvm.maxnan.v4f32 +;CHECK: ret void +define void @maxnan_f32(i32 %n, float* noalias %y, float* noalias %x, float* noalias %z) nounwind uwtable { +entry: + %cmp9 = icmp sgt i32 %n, 0 + br i1 %cmp9, label %for.body, label %for.end + +for.body: ; preds = %entry, %for.body + %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ] + %arrayidx = getelementptr inbounds float, float* %y, i64 %indvars.iv + %0 = load float, float* %arrayidx, align 4 + %arrayidx2 = getelementptr inbounds float, float* %z, i64 %indvars.iv + %1 = load float, float* %arrayidx2, align 4 + %call = tail call float @llvm.maxnan.f32(float %0, float %1) nounwind readnone + %arrayidx4 = getelementptr inbounds float, float* %x, i64 %indvars.iv + store float %call, float* %arrayidx4, align 4 + %indvars.iv.next = add i64 %indvars.iv, 1 + %lftr.wideiv = trunc i64 %indvars.iv.next to i32 + %exitcond = icmp eq i32 %lftr.wideiv, %n + br i1 %exitcond, label %for.end, label %for.body + +for.end: ; preds = %for.body, %entry + ret void +} Index: test/Transforms/Scalarizer/intrinsics.ll =================================================================== --- test/Transforms/Scalarizer/intrinsics.ll +++ test/Transforms/Scalarizer/intrinsics.ll @@ -5,6 +5,8 @@ ; Binary fp declare <2 x float> @llvm.minnum.v2f32(<2 x float>, <2 x float>) +declare <2 x float> @llvm.minnan.v2f32(<2 x float>, <2 x float>) +declare <2 x float> @llvm.maxnan.v2f32(<2 x float>, <2 x float>) ; Ternary fp declare <2 x float> @llvm.fma.v2f32(<2 x float>, <2 x float>, <2 x float>) @@ -40,6 +42,28 @@ ret <2 x float> %minnum } +; CHECK-LABEL: @scalarize_minnan_v2f32( +; CHECK: %minnan.i0 = call float @llvm.minnan.f32(float %x.i0, float %y.i0) +; CHECK: %minnan.i1 = call float @llvm.minnan.f32(float %x.i1, float %y.i1) +; CHECK: %minnan.upto0 = insertelement <2 x float> undef, float %minnan.i0, i32 0 +; CHECK: %minnan = insertelement <2 x float> %minnan.upto0, float %minnan.i1, i32 1 +; CHECK: ret <2 x float> %minnan +define <2 x float> @scalarize_minnan_v2f32(<2 x float> %x, <2 x float> %y) #0 { + %minnan = call <2 x float> @llvm.minnan.v2f32(<2 x float> %x, <2 x float> %y) + ret <2 x float> %minnan +} + +; CHECK-LABEL: @scalarize_maxnan_v2f32( +; CHECK: %maxnan.i0 = call float @llvm.maxnan.f32(float %x.i0, float %y.i0) +; CHECK: %maxnan.i1 = call float @llvm.maxnan.f32(float %x.i1, float %y.i1) +; CHECK: %maxnan.upto0 = insertelement <2 x float> undef, float %maxnan.i0, i32 0 +; CHECK: %maxnan = insertelement <2 x float> %maxnan.upto0, float %maxnan.i1, i32 1 +; CHECK: ret <2 x float> %maxnan +define <2 x float> @scalarize_maxnan_v2f32(<2 x float> %x, <2 x float> %y) #0 { + %maxnan = call <2 x float> @llvm.maxnan.v2f32(<2 x float> %x, <2 x float> %y) + ret <2 x float> %maxnan +} + ; CHECK-LABEL: @scalarize_fma_v2f32( ; CHECK: %fma.i0 = call float @llvm.fma.f32(float %x.i0, float %y.i0, float %z.i0) ; CHECK: %fma.i1 = call float @llvm.fma.f32(float %x.i1, float %y.i1, float %z.i1)