[PATCH] Constant Hoisting Pass

Juergen Ributzka juergen at apple.com
Wed Jan 22 17:31:36 PST 2014


Hi @ll,

this set of patches add a new pass called constant hoisting to the codegen pipeline. The idea behind this pass is to hoist and hide expensive constants, which forces them to be live-out/live-in of/into the basic block. This is done to work around the one-basic-block-a-time approach of SelectionDAG and friends. The intention is to prevent materialization of expensive integer constants in every single basic block and to keep them instead in registers. This pass sounds extremely like a CodeGenPrepare pass, but I had to spilt it out into a separate pass that just runs right before CodeGenPrepare. The reason for this is the horribly broken update code for the dominator tree in CodeGenPrepare. Luckily this code is currently dead, because the dominator tree is never available during CodeGenPrepare.

This pass will be extremely beneficial for JavaScript code, because it uses a lot of 64bit constants. I also tested it with the llvm test-suite, but it didn’t show a big change there. Interestingly I didn’t see any compile time increase. I actually have a few benchmarks that show a decrease in compile time in the 1-2% range, but that could also be just noise. Currently this pass will only affect X86, because that is the only target that implements the required target hooks. Other targets shouldn’t see any change.

The first patch simply updates TargetTransformInfo subclasses with the override and final keywords. Interestingly the method “finalizePass” is never called nor overrides a method from a base class.

The second patch extends TargetTransformInfo with additional target hooks for immediate costs, the constant hoisting pass, and the extensions to SelectionDAG for opaque constants. More details are in the attached patch.

Thanks for any review in advance.

Cheers,
Juergen

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-Add-final-and-owerride-keywords-to-TargetTransformIn.patch
Type: application/octet-stream
Size: 30464 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140122/d73e0680/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-Add-Constant-Hoisting-Pass.patch
Type: application/octet-stream
Size: 46048 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140122/d73e0680/attachment-0001.obj>


More information about the llvm-commits mailing list