[PATCH] Optimize square root squared (PR21126)
Sanjay Patel
spatel at rotateright.com
Thu Oct 2 13:05:42 PDT 2014
================
Comment at: test/Transforms/InstCombine/fmul.ll:130
@@ +129,3 @@
+declare double @llvm.sqrt.f64(double)
+attributes #0 = { "unsafe-fp-math"="true" }
+
----------------
hfinkel wrote:
> We don't need the "unsafe-fp-math"="true" because you're just checking the 'fast' on the fmul, right? If you don't need it, please remove it.
Thanks, Hal! Yes - the 'fast' alone is enough to do this optimization. I'm not a fan of the instruction-level fast-math flags...because it leads to another question. What should happen in the 2nd test case if it looks like this:
define double @sqrt_squared2(double %f) #0 {
%sqrt = call double @llvm.sqrt.f64(double %f)
%mul1 = fmul fast double %sqrt, %sqrt
%mul2 = fmul double %mul1, %sqrt
ret double %mul2
}
When the %mul1 operand is replaced in the 2nd fmul instruction, does that fmul instruction now become fast too? Is fast infectious?
http://reviews.llvm.org/D5584
More information about the llvm-commits
mailing list