https://godbolt.org/z/Y84oh497E
int m, n;
void func(int a){
m=a+a+a;
n=(m+m)/(m);
}
We note that the expression (m+m)/m is optimized to 2 if the number of a in the expression assigned to m is 2ⁿ, otherwise it is not optimized.
proof:
https://alive2.llvm.org/ce/z/y9amEc