[LLVMdev] Optimize away sqrt in simple cases?

Duncan Sands baldrick at free.fr
Tue Apr 23 13:29:22 PDT 2013


Hi Erkki,

On 23/04/13 22:12, Erkki Lindpere wrote:
> hi!
>
> I'm using LLVM 3.2. Does it optimize away llvm.pow(llvm.sqrt(x), 2) to `x` with
> any settings? I tried with llc -O3, but that didn't do it.

the most powerful optimizations are done by the "opt" tool, not llc.  That said,
I don't think any pass does this.  It would at least require "fast math".

Ciao, Duncan.

>
> Would be nice to write |v|² in my language ('v' being a 2D vector say and |...|
> and ...² being two separate infix "operators") -- when I could compare squares
> of lengths as well as lengths, and know that the sqrt is optimized away.
>
> Erkki
>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>




More information about the llvm-dev mailing list