@@ -83,10 +83,14 @@ const auto &float_func() {
8383 float_func[sub_float] = true ;
8484 float_func[mul_float] = true ;
8585 float_func[div_float] = true ;
86+ float_func[min_float] = true ;
87+ float_func[max_float] = true ;
8688 float_func[add_float_fast] = true ;
8789 float_func[sub_float_fast] = true ;
8890 float_func[mul_float_fast] = true ;
8991 float_func[div_float_fast] = true ;
92+ float_func[min_float_fast] = true ;
93+ float_func[max_float_fast] = true ;
9094 float_func[fma_float] = true ;
9195 float_func[muladd_float] = true ;
9296 float_func[eq_float] = true ;
@@ -134,7 +138,7 @@ uint32_t jl_get_LLVM_VERSION_impl(void)
134138 the bitcast function does nothing except change the type tag
135139 of a value. At the user-level, it is perhaps better known as reinterpret.
136140 boxing is delayed until absolutely necessary, and handled at the point
137- where the box is needed .
141+ where the box is nefeded .
138142 all intrinsics have a non-compiled implementation, this file contains
139143 the optimizations for handling them unboxed
140144*/
@@ -1490,6 +1494,34 @@ static Value *emit_untyped_intrinsic(jl_codectx_t &ctx, intrinsic f, ArrayRef<Va
14901494 case sub_float: return math_builder (ctx)().CreateFSub (x, y);
14911495 case mul_float: return math_builder (ctx)().CreateFMul (x, y);
14921496 case div_float: return math_builder (ctx)().CreateFDiv (x, y);
1497+ case min_float: {
1498+ assert (x->getType () == y->getType ());
1499+ FunctionCallee minintr = Intrinsic::getDeclaration (jl_Module, Intrinsic::minimum, ArrayRef<Type*>(t));
1500+ return ctx.builder .CreateCall (minintr, {x, y});
1501+ }
1502+ case max_float: {
1503+ assert (x->getType () == y->getType ());
1504+ FunctionCallee maxintr = Intrinsic::getDeclaration (jl_Module, Intrinsic::maximum, ArrayRef<Type*>(t));
1505+ return ctx.builder .CreateCall (maxintr, {x, y});
1506+ }
1507+ case min_float_fast: {
1508+ assert (x->getType () == y->getType ());
1509+ FunctionCallee minintr = Intrinsic::getDeclaration (jl_Module, Intrinsic::minimum, ArrayRef<Type*>(t));
1510+ auto call = ctx.builder .CreateCall (minintr, {x, y});
1511+ auto fmf = call->getFastMathFlags ();
1512+ fmf.setFast ();
1513+ call->copyFastMathFlags (fmf);
1514+ return call;
1515+ }
1516+ case max_float_fast: {
1517+ assert (x->getType () == y->getType ());
1518+ FunctionCallee maxintr = Intrinsic::getDeclaration (jl_Module, Intrinsic::maximum, ArrayRef<Type*>(t));
1519+ auto call = ctx.builder .CreateCall (maxintr, {x, y});
1520+ auto fmf = call->getFastMathFlags ();
1521+ fmf.setFast ();
1522+ call->copyFastMathFlags (fmf);
1523+ return call;
1524+ }
14931525 case add_float_fast: return math_builder (ctx, true )().CreateFAdd (x, y);
14941526 case sub_float_fast: return math_builder (ctx, true )().CreateFSub (x, y);
14951527 case mul_float_fast: return math_builder (ctx, true )().CreateFMul (x, y);
0 commit comments