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

            Bug ID: 96831
           Summary: gcc.dg/tree-ssa/scev-[345].c FAIL on i?86 and arm
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rguenth at gcc dot gnu.org
  Target Milestone: ---

The testcases now FAIL after dumping TARGET_MEM_REF bases as &a instead of
symbol: a and thus show that IVOPTs doesn't consider using a pointer IV:

For lp64 (x86_64) I see

  <bb 4> :
  _10 = (sizetype) k_4(D);
  _8 = _10 * 8;
  _6 = (sizetype) k_4(D);
  _3 = _6 * 8;
  _2 = _3 + 4;
  _1 = &a + _2;
  ivtmp.5_7 = (unsigned long) _1;

  <bb 5> :
  # i_12 = PHI <k_4(D)(4), i_9(6)>
  # ivtmp.5_5 = PHI <ivtmp.5_7(4), ivtmp.5_11(6)>
  _1_16 = (int *) ivtmp.5_5;
  a_p = _1_16;
  _19 = (void *) ivtmp.5_5;
  MEM[(int *)_19] = 100;
  i_9 = k_4(D) + i_12;
  ivtmp.5_11 = ivtmp.5_5 + _8;
  if (i_9 <= 999)

so the ADDRESS use and the dereference use use the same IV.  But with ilp32
we end up with

  <bb 5> :
  # i_12 = PHI <k_4(D)(4), i_9(6)>
  _5 = (unsigned int) &a;
  _11 = (unsigned int) i_12;
  _10 = _11 * 8;
  _8 = _5 + _10;
  _7 = _8 + 4;
  _6 = (int *) _7;
  _1_16 = _6;
  a_p = _1_16;
  _3 = (sizetype) i_12;
  MEM[(int *)&a + _3 * 8] = 100;
  i_9 = k_4(D) + i_12;
  if (i_9 <= 999)

(scev-4.c) and eventually

.L2:
        movl    $100, a+4(,%eax,8)
        leal    a+4(,%eax,8), %ecx
        addl    %edx, %eax
        cmpl    $999, %eax
        jle     .L2
        movl    %ecx, a_p

instead of

.L3:
        addl    %edi, %ecx
        movl    $100, (%rax)
        movq    %rax, %rsi
        addq    %rdx, %rax
        cmpl    $999, %ecx
        jle     .L3
        movq    %rsi, a_p(%rip)

it's not entirely clear whether based on costs one is better than the other
(we are not able to replace the COMPARE use and thus the tested for variant
uses one more IV).

Reply via email to