How to read a SelectionDAG?

The image below shows a DAG that was created for a sum function.
1.What does the “[ORD = 1]” specifies in the SDNodes?
2. What do the numbers written at the top of the SDnodes specify?
Kindly help… :slightly_smiling_face:

It represents the ordering used to assist scheduling: llvm-project/SelectionDAGNodes.h at 530d14a99611a71f8f3eb811920fd7b5c4d4e1f8 · llvm/llvm-project · GitHub

They’re operand indices. For instance, the first operand (index 0) of the add node is coming from the CopyFromReg node because there is an edge between CopyFromReg and the said operand.

Also, numbers below a node are its result indices. Unlike LLVM instructions, a SDNode can generate multiple results (i.e. SDValue).

1 Like