Menu

#1930 gcc-torture-execute-pr20466-1 fails

closed-fixed
redundancy elimination
6
2023-01-10
2012-02-10
No

When removing the preprocessor guard, the gcc-torture-execute-pr20466-1 regression test fails for all ports in revision #7290.

Philipp

Related

Wiki: SDCC 4.3.0 Release

Discussion

  • Erik Petrich

    Erik Petrich - 2012-03-06
    • labels: --> pointer aliasing
     
  • Sergey Belyashov

    I have added more checks to the test:

    int
    f (int **ipp, int *i1p, int *i2p, int **i3, int **i4)
    {
      **ipp = *i1p;
      *ipp = i2p;
      *i3 = *i4;
      **ipp = 99;
      return 3;
    }
    
    void
    testTortureExecute (void)
    {
      int i = 42, i1 = 66, i2 = 1, i3 = -1, i4 = 55;
      int *ip = &i;
      int *i3p = &i3;
      int *i4p = &i4;
    #if !(defined(__SDCC_pic14) && !defined(__SDCC_PIC14_ENHANCED)) // Pseudo-stack size limit
      f (&ip, &i1, &i2, &i3p, &i4p);
      ASSERT(i == 66);
      ASSERT(ip == &i2);
      ASSERT(i2 == 99);
      ASSERT(i3 == -1);
      ASSERT(i3p == i4p);
      ASSERT(i4 == 55);
      if (i != 66 || ip != &i2 || i2 != 99 || i3 != -1 || i3p != i4p || i4 != 55)
        ASSERT (0);
      return;
    #endif
    }
    

    Result: FAIL: "Assertion failed" on i2 == 99
    Next I look into generated asm file:

    ...
    ;gen/ucz80/gcc-torture-execute-pr20466-1/gcc-torture-execute-pr20466-1.c:18: *i3 = *i4;
    ;       genAssign
    ;       AOP_STK for
    ;fetchPairLong
            ld      c, 10 (ix)
            ld      b, 11 (ix)
    ;       genAssign
    ;       AOP_STK for
    ;fetchPairLong
            ld      l, 12 (ix)
            ld      h, 13 (ix)
    ;       genPointerGet
    ;fetchPairLong
    ;       _moveFrom_tpair_()
            ld      e, (hl)
            inc     hl
    ;       _moveFrom_tpair_()
            ld      d, (hl)
    ;       genAssign (pointer)
    ;       isBitvar = 0
    ;fetchPairLong
            ld      a, e
            ld      (bc), a
            inc     bc
            ld      a, d
            ld      (bc), a
    ;gen/ucz80/gcc-torture-execute-pr20466-1/gcc-torture-execute-pr20466-1.c:20: return 3;
    ...
    

    So **ipp = 99; was eliminated out. Why?

     
  • Sergey Belyashov

    Continue investigation...
    Operation is marked dead by CSE and GCSE (any one) optimizations. It is eliminated on line SDCCopt.c:3207 by killDeadCode().

    More deep investigation should do cse hacker :-)

     

    Last edit: Sergey Belyashov 2020-08-03
  • Sergey Belyashov

    • Category: --> redundancy elimination
     
  • Erik Petrich

    Erik Petrich - 2023-01-10
    • status: open --> closed-fixed
    • assigned_to: Erik Petrich
     
  • Erik Petrich

    Erik Petrich - 2023-01-10

    Fixed in [r13788]

     

    Related

    Commit: [r13788]


Log in to post a comment.

MongoDB Logo MongoDB