[LLVMdev] Optimization of calls to functions without side effects (from Kaleidoscope example)

Arnaud Allard de Grandmaison Arnaud.AllardDeGrandMaison at dibcom.com
Wed Nov 17 00:19:35 PST 2010


Hi Dan,

>Did the code in the tutorial work at some point? Offhand, I wouldn't expect
>any of my recent changes to have affected this. I'm reluctant to fix this
>without understanding how the original code was intended to work.

The code works, but not as shown in the tutorial. In the tutorial, it shows that multiple calls to pure functions (sin, cos) can be optimized. Without the patch, this does not show up any longer. So we need to update either the tutorial or the code.

I think it is better to tweak the source code, because it is a good demonstration of what llvm can do. The tutorial/Chapter 4 is about JIT & optimizer; 2 optimizations are demonstrated  : constant folding and pure functions handling. Only showing constant folding does not seem very appealing for an optimizer :)

Best regards,
--
Arnaud de Grandmaison

-----Original Message-----
From: Dan Gohman [mailto:gohman at apple.com]
Sent: Tuesday, November 16, 2010 6:45 PM
To: Arnaud Allard de Grandmaison
Cc: llvmdev at cs.uiuc.edu
Subject: Re: [LLVMdev] Optimization of calls to functions without side effects (from Kaleidoscope example)


On Nov 16, 2010, at 1:19 AM, Arnaud Allard de Grandmaison wrote:

> Hi Dan,
>
> The tutorial in r119335 does not build : the basicAA pass creation needs to be declared. This is addressed with the 'missing-include' patch, which updates both source code & documentation.

Applied, thanks.

> The second point is that beside basicAA, to get the optimizations as shown in the tutorial, (sin(x)*sin(x) -> sin(x)^2), some attributes need to be set on 'sin'. Patch 'set-attribute' address this. Of course, this is probably not the right way to achieve this in real life with a real programming language / environment, but within the scope of the kaleidoscope, this should be sufficient. This patch updates both the source code & documentation.

Did the code in the tutorial work at some point? Offhand, I wouldn't expect
any of my recent changes to have affected this. I'm reluctant to fix this
without understanding how the original code was intended to work.

Dan


CONFIDENTIAL NOTICE: The contents of this message, including any attachments, are confidential and are intended solely for the use of the person or entity to whom the message was addressed. If you are not the intended recipient of this message, please be advised that any dissemination, distribution, or use of the contents of this message is strictly prohibited. If you received this message in error, please notify the sender. Please also permanently delete all copies of the original message and any attached documentation. Thank you.




More information about the llvm-dev mailing list