Hi,

With PowerPC GCC tool chain v4.6.1 (for e500mc), i have a test case
which shows regression at -O3 with the patch [IRA-based register
pressure calculation for RTL loop invariant motion] listed below:

http://gcc.gnu.org/ml/gcc-patches/2009-09/msg01889.html

Reduced Test Case:
/***************************************************************************************/
extern int a;
int asdf (int x);
char buf[32];
int test (void) {
  int i, x;

  for (i = 0 ; i < a; i++) {
   asm ("stfd %0,0(%1)" : : "d" (8.9731144674927890e20), "b" (buf));
    x += asdf(i);
  }
  return x;
/****************************************************************************************/

Code Generated:
test:
        ....
      ble- 7,.L2
        lis 26,.LC0@ha
        lis 30,buf@ha
        lis 27,.LC1@ha
        li 31,0
        la 26,.LC0@l(26)
        la 30,buf@l(30)
        la 27,.LC1@l(27)
        la 28,a@l(28)
        .p2align 4,,15
.L3:
        lfd 0,0(26)      ----------------------(A)
#APP
 # 9 "test.c" 1
        stfd 0,0(30)
 # 0 "" 2
#NO_APP
        lis 30,buf@ha   ---------------(B)
        lfd 0,0(27)         ---------------(C)
        la 30,buf@l(30) ----------------(D)
#APP
 # 10 "test.c" 1
        stfd 0,8(30)
 # 0 "" 2
#NO_APP
        mr 3,31
        bl asdf
        lwz 0,0(28)
        addi 31,31,1
        add 29,29,3
        cmpw 7,0,31
        bgt+ 7,.L3
.L2:
        lwz 0,36(1)


           ...
Here we can see that the load of the constant values (A, B, C, D) are
inside the loop.
The ‘loop invariant code motion’ pass identifies that these
instructions (const value load instructions) can be moved outside the
loop. But with  flag ‘-fira-loop-pressure’ ON [IRA-based register
pressure calculation for RTL loop invariant motion], the heuristic
determines that this is not profitable.

And with ‘-O3’ and above, we cannot switch OFF the flag
‘-fira-loop-pressure’, because it has been explicitly overridden in
the PPC backend target files.

1) Is it possible to update the heuristic to allow this optimization.
2) If not, the user should have control over the '-fira-loop-pressure'
flag when passed explicitly.

         File: rs6000.c
         if (optimize >= 3 && global_init_p &&
!global_options_set.x_flag_ira_loop_pressure)
            flag_ira_loop_pressure = 1;

Regards,
Rohit

Reply via email to