O'Reilly logo

LLVM Cookbook by Suyog Sarda, Mayur Pandey

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Optimizing SelectionDAG

A SelectionDAG representation shows data and instructions in the form of nodes. Similar to the InstCombine pass in the LLVM IR, these nodes can be combined and optimized to form a minimized SelectionDAG. But, it's not just a DAGCombine operation that optimizes the SelectionDAG. A DAGLegalize phase may generate some unnecessary DAG nodes, which are cleaned up by subsequent runs of the DAG optimization pass. This finally represents the SelectionDAG in a more simple and elegant way.

How to do it…

There are lots and lots of function members (most of them are named like this: visit**()) provided in the DAGCombiner class to perform optimizations by folding, reordering, combining, and modifying SDNode nodes. Note that, from the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required