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

            Bug ID: 70053
           Summary: Returning a struct of _Decimal128 values generates
                    extraneous stores and loads
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bergner at gcc dot gnu.org
  Target Milestone: ---

If we compile the following testcase, we see uneeded stores to the stack
followed by immediate loads from the same stack slots just before the return. 
One set of stores/loads is completely unneeded and the others can be replaced
by simple fmrs.

bergner@genoa:~/gcc/BUGS/DFP/arith128-P8AT9/src$ cat t.i 
typedef struct
{
  _Decimal128 td0;
  _Decimal128 td1;
} TDx2_t;


TDx2_t
D256_add_finite (_Decimal128 a, _Decimal128 b, _Decimal128 c)
{
  TDx2_t result;

  result.td0 = a;
  result.td1 = b;

  if (b == c)
  {
    result.td0 = c;
    result.td1 = c;
    return result;
  }

  return result;
}

bergner@genoa:~/gcc/BUGS/DFP/$
/home/bergner/gcc/build/gcc-fsf-mainline-base-debug/gcc/xgcc
-B/home/bergner/gcc/build/gcc-fsf-mainline-base-debug/gcc -O2 -mcpu=power8 -S
t.i 
bergner@genoa:~/gcc/BUGS/DFP/$ cat t.s 
        .file   "t.i"
        .abiversion 2
        .section        ".text"
        .align 2
        .p2align 4,,15
        .globl D256_add_finite
        .type   D256_add_finite, @function
D256_add_finite:
        dcmpuq 7,4,6
        beq 7,.L5
        stfd 3,-64(1)
        stfd 2,-56(1)
        stfd 5,-48(1)
        stfd 4,-40(1)
        ori 2,2,0
        lfd 3,-64(1)
        lfd 2,-56(1)
        lfd 5,-48(1)
        lfd 4,-40(1)
        blr
        .p2align 4,,15
.L5:
        stfd 7,-64(1)
        stfd 6,-56(1)
        stfd 7,-48(1)
        stfd 6,-40(1)
        ori 2,2,0
        lfd 3,-64(1)
        lfd 2,-56(1)
        lfd 5,-48(1)
        lfd 4,-40(1)
        blr

Reply via email to