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

--- Comment #19 from Pengfei Li <pfustc at gcc dot gnu.org> ---
A further simplified case from Andrew's original one:

union u {
  long l;
  int i[2];
};
inline long convert(int i) {
  u t;
  t.i[0] = i;
  return t.l;
}
long foo(int x, unsigned int n) {
  long y = -1;
  for (int i = 0; i < n; i++) {
    x = x * 2;
    y = convert(x);
  }
  return y;
}

GCC emits below code for the loop in foo():

.L3:
        lsl     w2, w2, 1
        add     w3, w3, 1
        bfi     x4, x2, 0, 32
        mov     x0, x4
        cmp     w1, w3
        bne     .L3

While LLVM emits:

.LBB0_1:
        lsl     w0, w0, #1
        subs    w1, w1, #1
        b.ne    .LBB0_1

Are you still working on fixing this, @Andrew?

Reply via email to