Search code examples
compiler-constructionllvmcompiler-optimization

Sample program where MOP and MFP are different


I am studying the comparison between Meet over all path(MOP) and Maximum Fixed Point(MFP) in compiler optimizations. Its been said that MFP is a subset of MOP. But I couldn't find out an example in which MFP and MOP are different. Can anyone help me out with any sample program in which MFP and MOP gives different results.


Solution

  • There is such an example in "Monotone Data Flow Analysis Framework" by Kam and Ullman refer this.

    A sample program is

    if(<some codition>) {
      A = 2;
      B = 3;
    }
    else {
      A = 3;
      B = 2;
    }
    C=A+B;
    

    If we consider the constant propagation analysis of the above program the variable C is a constant in every case. The value will be 5 if the if statement condition evaluates to true or false. But if we perform a fixed point analysis on the above program the C will never be considered as a constant whereas a MOP analysis will provide the information that C is a constant.