LLVM Discussion Forums

How to get values related to conditional branch

I want to get the values in a conditional branch. For example, the value of “a, b” in “if (a+b>7)”.
Specifically,

       %4 = icmp eq i32 %3, 3
       br i1 %4, label %5, label %7

First, I use the inst.isConditional() to find the conditional branch. But I want to get the value of “%3” and “3”, which are the data for this conditional branch. (The operands in the instruction “%4”).
So, how can I get the value of the operands in “%4”?
Maybe, the label “%4” can help, but I don’t know how to use the label.
Thank you every one!

The %4 in your example is the first operand of the conditional, you can access it by calling getCondition() (after checking isConditional())

Thanks. I will try that.