1; REQUIRES: asserts 2; RUN: llc -mtriple=x86_64-unknown-unknown -mattr=avx512f -debug-only=isel < %s -o /dev/null 2>&1 | FileCheck %s 3 4; This tests the propagation of fast-math-flags from IR instructions to SDNodeFlags. 5 6; CHECK-LABEL: Initial selection DAG: %bb.0 'fmf_transfer:' 7 8; CHECK: t5: f32 = fadd nsz t2, t4 9; CHECK-NEXT: t6: f32 = fadd arcp t5, t4 10; CHECK-NEXT: t7: f32 = fadd nnan t6, t4 11; CHECK-NEXT: t8: f32 = fadd ninf t7, t4 12; CHECK-NEXT: t9: f32 = fadd contract t8, t4 13; CHECK-NEXT: t10: f32 = fadd afn t9, t4 14; CHECK-NEXT: t11: f32 = fadd reassoc t10, t4 15; CHECK-NEXT: t12: f32 = fadd nnan ninf nsz arcp contract afn reassoc t11, t4 16 17; CHECK: Optimized lowered selection DAG: %bb.0 'fmf_transfer:' 18 19define float @fmf_transfer(float %x, float %y) { 20 %f1 = fadd nsz float %x, %y 21 %f2 = fadd arcp float %f1, %y 22 %f3 = fadd nnan float %f2, %y 23 %f4 = fadd ninf float %f3, %y 24 %f5 = fadd contract float %f4, %y 25 %f6 = fadd afn float %f5, %y 26 %f7 = fadd reassoc float %f6, %y 27 %f8 = fadd fast float %f7, %y 28 ret float %f8 29} 30 31; CHECK-LABEL: Optimized type-legalized selection DAG: %bb.0 'fmf_setcc:' 32; CHECK: t13: i8 = setcc nnan ninf nsz arcp contract afn reassoc t2, ConstantFP:f32<0.000000e+00>, setlt:ch 33 34define float @fmf_setcc(float %x, float %y) { 35 %cmp = fcmp fast ult float %x, 0.0 36 %ret = select i1 %cmp, float %x, float %y 37 ret float %ret 38} 39 40; CHECK-LABEL: Initial selection DAG: %bb.0 'fmf_setcc_canon:' 41; CHECK: t14: i8 = setcc nnan ninf nsz arcp contract afn reassoc t2, ConstantFP:f32<0.000000e+00>, setgt:ch 42define float @fmf_setcc_canon(float %x, float %y) { 43 %cmp = fcmp fast ult float 0.0, %x 44 %ret = select i1 %cmp, float %x, float %y 45 ret float %ret 46} 47 48declare <16 x float> @llvm.x86.avx512.vfmadd.ps.512(<16 x float>, <16 x float>, <16 x float>, i32) 49 50; Check that FMF are propagated twice: from IR to x86-specific node and from x86-specific node to generic node. 51 52; CHECK-LABEL: Initial selection DAG: %bb.0 'fmf_target_intrinsic:' 53; CHECK: v16f32 = llvm.x86.avx512.vfmadd.ps.512 ninf nsz TargetConstant:i64<{{.*}}> 54; CHECK: v16f32 = llvm.x86.avx512.vfmadd.ps.512 nsz TargetConstant:i64<{{.*}}> 55 56; CHECK-LABEL: Legalized selection DAG: %bb.0 'fmf_target_intrinsic:' 57; CHECK: v16f32 = fma ninf nsz t{{.*}} 58; CHECK: v16f32 = fma nsz t{{.*}} 59 60define <16 x float> @fmf_target_intrinsic(<16 x float> %a, <16 x float> %b, <16 x float> %c) nounwind { 61 %t0 = tail call ninf nsz <16 x float> @llvm.x86.avx512.vfmadd.ps.512(<16 x float> %a, <16 x float> %b, <16 x float> %c, i32 4) 62 %t1 = tail call nsz <16 x float> @llvm.x86.avx512.vfmadd.ps.512(<16 x float> %t0, <16 x float> %b, <16 x float> %c, i32 4) 63 ret <16 x float> %t1 64} 65