This isn't so much a patch as it is a tool for discussion. We shouldn't need constrained intrinsics for copysign/fabs/fneg since they are bitwise operations (assuming the intrinsics map to libm functions). They never trap and are not influenced by the rounding mode.
That said, there are cases where copysign/etc optimizations can result in trap-unsafe code. E.g.:
define double @safe(float %a, double %b) "unsafe-fp-math"="false" {
%r1 = call float @llvm.copysign.f32(float 1.000000e+00, float %a) %r2 = fpext float %r1 to double %r3 = call double @llvm.copysign.f64(double %b, double %r2) ret double %r3
}
In this example, the 1st copysign is sanitizing a potential SNaN so that the fpext does not trap on it. LLVM will currently optimize this sequence to remove the 1st copysign, which may lead to a FE_INVALID trap on the fpext.
As long as we add constrained intrinsics for the fpext (and friends), we won't be able to optimize the copysign in an unsafe way. So, I think we're good with just that.
In conclusion, we don't need constrained intrinsics for copysign/fabs/fneg, but we should be wary of how they're optimized in the presence of constrained converts.
Does this sound correct to everyone? Did I miss anything?