This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: gcse pass: expression hash table


My assumption here was that if I gave you a few pointers, you would try
to debug the problem yourself.  If you want someone else to debug it for
you, then you need to give much better info.  See for instance
   http://gcc.gnu.org/bugs.html
which gives info on how to properly report a bug.  I have the target and
gcc version, but I need a testcase, compiler options, and perhaps other
info.

I will take this into consideration now onwards.


The test case I am using (for multiplication expression is)
----------------------------
#include<stdio.h>

void foo();

int main()
{
        foo();
}
void foo()
{
        int a, b, c;
        int cond;

        scanf(" %d %d %d", &a, &b, &cond);
        if( cond )
                c = a * b;
        c = a * b;
        printf("Value of C is %d", c);
}
------------------------------
and for plus, a*b replaced by a+b everywhere.

I am compiling it as

gcc --param max-gcse-passes=2 -dF -dG -O3 filename.c

The reason for max-gcse-passes=2 is that in first pass a+b kind of expressions will be using different sets of pseudo registers at first and second occurance of a+b. After one gcse pass, both will become same (because of intermediate constant/copy propagation passes).
Then a+b gets optimized. As can be seen from dumps


filename.c.07.addressof
and filename.c.08.gcse

A part of expression hash table for program containing plus is

Expression hash table (11 buckets, 11 entries)

Index 0 (hash value 3)
  (plus:SI (reg/f:SI 20 frame)
    (const_int -4 [0xfffffffc]))

....

Index 8 (hash value 1)
  (mem/f:SI (plus:SI (reg/f:SI 20 frame)
        (const_int -8 [0xfffffff8])) [2 b+0 S4 A32])
Index 9 (hash value 6)
  (plus:SI (reg:SI 78 [ a ])
    (reg:SI 79 [ b ]))
Index 10 (hash value 10)
  (plus:SI (reg:SI 80 [ a ])
    (reg:SI 81 [ b ]))

Which clearly shows that clobbering CC in a+b is being ignored if the expressions which requires to be inserted will not be containing clobbering of CC.

How do you know that adds are getting optimized? Did you judge this by

I am looking at dump files.


looking at one of the dump files, or looking at the assembly output?
Maybe you are looking at the wrong thing, or misunderstanding what you
are looking at?  You need to give more details here.

Regards, -tarun


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]