I am trying to see whether or not the GCC applies partial dead code elimination optimization.
Partial dead code elimination can be considered as the result of the two opt passes: assignment sinking + dead code elimination. For example
x = 3;
y = p + q; y = p + q; y = p + q;
if(cond) then if(cond) then if(cond) then
x = 5; assn sinking x = 3; dead code eln x = 5;
p = p*q; -----------> x = 5; -------------> p = p*q;
else p = p*q; else
q = p*q; else x = 3;
end if; x = 3; q = p*q;
out(x); q = p*q; end if;
end if; out(x)
out(x)
I have tried the following things.
Remark: all of my observations are based on dump files dumped at Gimple level, not at RTL level.
GCC version on my computer: gcc (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0.
I tried compiling my code with the following command:
gcc -O3 -fdump-tree-all pde.c
I am getting the following dump files. There is one named pde.c.134t.sink where it is expected to see the forward store motion according to GCC 7.4.0 documentation. But I am not able to find any type of code motion at any of the gimple level dump files. I am not sure about whether it is doing the code motion at the RTL level? I have tried a lot of benchmarks and I have never seen assignment sinking/ partial dead code elimination at Gimple level.
Question1: Does GCC apply assignment sinking / partial dead code elimination?
Question2: If yes then where can I see this?