https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91682

            Bug ID: 91682
           Summary: IPA-cp can not propagate value for by-ref argument in
                    form of *arg = param op constant
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: ipa
          Assignee: unassigned at gcc dot gnu.org
          Reporter: fxue at os dot amperecomputing.com
                CC: marxin at gcc dot gnu.org
  Target Milestone: ---

Current IPA only supports CP on by-ref argument assigned with constant. But if
value of the argument is computed via an unary/binary operation on caller's
parameter, it fails to do that. For example.

   struct S
     {
       int a, b;
     };

   void callee2 (struct S *s)
     {
        // use s->a;
        // use s->b; 
     }

   void callee1 (int a, int *p)
     {
       struct S s;

       s.a = a;
       s.b = *p + 1;
       callee2 (&s);
     }

   void caller ()
     {
        int a = 1;
        int b = 2;

        callee1 (a, &b);
     } 

In callee1(), we could know that value of s.a equals 1 and s.b is 3, it is
possible to propagate these value to callee2().

Reply via email to