https://bugs.llvm.org/show_bug.cgi?id=48981

            Bug ID: 48981
           Summary: [AVR] Bad optimization of multiplication when mul
                    instruction is available
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: AVR
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]

int square(int num)
{
    return num * num;
}

GCC -O3 generates this:

square(int):
  movw r18,r24
  mul r18,r18
  movw r24,r0
  mul r18,r19
  add r25,r0
  add r25,r0
  clr r1
  ret

LLVM generates this:

square(int):
  muls r25, r24
  mov r18, r0
  clr r1
  muls r24, r25
  mov r19, r0
  clr r1
  mul r24, r24
  mov r20, r1
  clr r1
  add r20, r19
  add r20, r18
  lsl r20
  rol r21
  lsl r20
  rol r21
  lsl r20
  rol r21
  lsl r20
  rol r21
  lsl r20
  rol r21
  lsl r20
  rol r21
  lsl r20
  rol r21
  lsl r20
  rol r21
  mov r24, r0
  clr r25
  or r24, r20
  or r25, r21
  ret

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to