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

            Bug ID: 82989
           Summary: Inexplicable use of NEON for 64-bit math
           Product: gcc
           Version: 7.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: matthijsvanduin at gmail dot com
  Target Milestone: ---

The following function:

    void foo( uint64_t *a ) {
        *a += *a >> 32;
    }

compiled with  arm-linux-gnueabihf-gcc -mcpu=cortex-a8 -mfpu=neon -O2
produces the following code:

      push      {r4, r5}
      ldrd      r4, [r0]
      vmov      d16, r4, r5
      vshr.u64  d16, d16, #32
      vmov      r2, r3, d16
      adds      r2, r2, r4
      adcs      r3, r3, r5
      strd      r2, [r0]
      pop       {r4, r5}
      bx        lr

Since -mneon-for-64bits is not enabled (I double-checked using -Q just to be
sure), the use of neon instructions here is highly unexpected.

(Moreover, shifting right by 32 bits should of course not involve any actual
arithmetic whatsoever.  Ideally this function would compile to

      ldrd      r2, [r0]
      adds      r2, r2, r3
      adcs      r3, r3, #0
      strd      r2, [r0]
      bx        lr

)

Reply via email to