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 ...
Get LLVM Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.