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

            Bug ID: 78120
           Summary: [6/7 Regression] If conversion no longer performed
           Product: gcc
           Version: 7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ubizjak at gmail dot com
  Target Milestone: ---

For the following testcase, RTL if-conversion is no longer performed:

--cut here--
typedef unsigned long u64;

typedef struct {
  u64 hi, lo;
} u128;

static inline u128 add_u128 (u128 a, u128 b)
{
  a.lo += b.lo;
  if (a.lo < b.lo)
    a.hi++;

  return a;
}

extern u128 t1, t2, t3;

void foo (void)
{
  t1 = add_u128 (t1, t2);
  t1 = add_u128 (t1, t3);
}
--cut here--

gcc-7 compiles (-O2) to:

--cut here--
foo:
        movq    t1+8(%rip), %rax
        addq    t2+8(%rip), %rax
        movq    t1(%rip), %rdx
        jc      .L12
.L4:
        addq    t3+8(%rip), %rax
        jc      .L13
.L7:
        movq    %rdx, t1(%rip)
        movq    %rax, t1+8(%rip)
        ret
.L12:
        addq    $1, %rdx
        jmp     .L4
.L13:
        addq    $1, %rdx
        jmp     .L7
--cut here--

gcc-5 is able to perform if-conversion in _r.ce1 pass, resulting in:

--cut here--
foo:
        movq    t2+8(%rip), %rax
        addq    t1+8(%rip), %rax
        movq    t1(%rip), %rdx
        adcq    $0, %rdx
        addq    t3+8(%rip), %rax
        adcq    $0, %rdx
        movq    %rax, t1+8(%rip)
        movq    %rdx, t1(%rip)
        ret
--cut here--

Reply via email to