[LLVMdev] opts do not occur in some situations?

Azriel Fasten fst911 at gmail.com
Sun Dec 7 00:13:21 PST 2008


Hi, I'm trying to understand the optimization passes. I was wondering
why some seemingly obvious optimizations don't occur in some
situations. For example, the attached file, main.opt.cpp compiles to
main.opt.ll ( after running opt -std-compile-opts ).

	%0 = tail call double @_Z9factorialIdET_S0_(double 0.000000e+000)		;
<double> [#uses=1]

which could easily be determined as 1. And then multiplying the
remaining numbers manually?

	%phitmp93 = mul double %0, 2.000000e+000		; <double> [#uses=1]
	%phitmp94 = mul double %phitmp93, 3.000000e+000		; <double> [#uses=1]
...
...
	%phitmp108 = mul double %phitmp107, 1.800000e+001		; <double> [#uses=1]
	%phitmp109 = mul double %phitmp108, 1.900000e+001		; <double> [#uses=1]
	%1 = tail call i32 (i8*, ...)* @printf(i8* getelementptr ([29 x i8]*
@.str, i32 0, i32 0), double %phitmp109) nounwind		; <i32> [#uses=0]

This only occurs when using factorial( (double)19 ). factorial(
(double)18 ) results in the much shorter:

	%0 = tail call i32 (i8*, ...)* @printf(i8* getelementptr ([29 x i8]*
@.str, i32 0, i32 0), double 0x4336BEECCA730000) nounwind		; <i32>
[#uses=0]

I am just wondering whats going on over here.

Thank you.
--
Azriel Fasten
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: main.opt.cpp
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20081207/3eb2a01c/attachment.ksh>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: main.opt.ll
Type: application/octet-stream
Size: 5332 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20081207/3eb2a01c/attachment.obj>


More information about the llvm-dev mailing list