int func(int i){
int j;
j = i + 0;
return j;
}
I want to practise and learn LLVM transformation pass.
For the above simple c function, I want to implement algebraic identification optimization X+0 -> X
I expect the optimized program to be
int func(int i){
int j;
j = i // remove the add instruction
return j;
}
I read about the IRBuilder, I can create Add/Sub/Mul.... a lot of instructions. But for handling the above case, I can not find any matches.
what should I do to handle the above case?
I also think if I can just remove the instruction.
And the program would be
int func(int i){
return i;
}
I am not sure if llvm will do this automatically, once I remove the useless add instruction.