This is the mail archive of the gcc-bugs@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]

[Bug tree-optimization/62631] gcc.dg/tree-ssa/ivopts-lt-2.c FAILs


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

--- Comment #4 from bin.cheng <amker.cheng at gmail dot com> ---
Hi Rainer,
This is caused by abnormal huge cost of function call `shiftadd_cost (true,
DImode, 2)'.  It returns 100+ cost, resulting in huge cost when representing
use 1 with cand 4:

use 1
  compare
  in statement if (i_12 <= 99)

  at position 
  type unsigned int
  base i_4(D) + 1
  step 1
  is a biv
  related candidates 

  i_4(D) is invariant (2), eliminable
  p_8 is invariant (1), eliminable

candidate 4 (important)
  original biv
  type int *
  base p_8
  step 4
  base object (void *) p_8

Use 1:
  cand    cost    compl.    depends on
  0    4    0     inv_expr:0
  1    4    0    
  4    23    0     inv_expr:1   <------huge cost.
  5    0    0
  6    0    0    
  8    4    1    

I worked out a patch fixing this from ivopt.  Because I am not firmiliar with
sparc ISA, could you please help me confirm that below fixed assembly is better
than the original version?

The orignal assembly:
f1:
    sllx    %o1, 2, %g1
    add    %o0, %g1, %o0
.LL2:
    st    %g0, [%o0]
    add    %o1, 1, %g1
    add    %o0, 4, %o0
    cmp    %g1, 99
    bleu,pt    %icc, .LL2
     srl    %g1, 0, %o1
    jmp    %o7+8
     nop
    .size    f1, .-f1

The fixed version assembly:
f1:
    .register    %g2, #scratch
    sllx    %o1, 2, %g1
    mov    99, %g2
    add    %o0, %g1, %o0
    sub    %g2, %o1, %o1
    srl    %o1, 0, %g1
    add    %g1, 1, %g1
    sllx    %g1, 2, %g1
    add    %o0, %g1, %g1
    st    %g0, [%o0]
.LL5:
    add    %o0, 4, %o0
    cmp    %o0, %g1
    blu,a,pt %xcc, .LL5
     st    %g0, [%o0]
    jmp    %o7+8
     nop
    .size    f1, .-f1

Though it has larger loop setup code, the loop itself is simplified.

If yes, I will send out the patch for review.

Thanks,
bin


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