[Bug target/82182] New: m68k slow code: u16/u8 division calls divsi3
cand at gmx dot com
gcc-bugzilla@gcc.gnu.org
Mon Sep 11 18:02:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82182
Bug ID: 82182
Summary: m68k slow code: u16/u8 division calls divsi3
Product: gcc
Version: 7.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: cand at gmx dot com
Target Milestone: ---
C:
#include <stdint.h>
uint16_t mydiv(const uint16_t a, const uint8_t b) {
return a / b;
}
uint16_t mydiv2(const uint16_t a, const uint16_t b) {
return a / b;
}
Assembly:
#NO_APP
.file "kai.c"
.globl __udivsi3
.globl __divsi3
.text
.align 2
.globl mydiv
.type mydiv, @function
mydiv:
moveq #0,%d0
move.w 6(%sp),%d0
moveq #0,%d1
move.b 11(%sp),%d1
move.l %d1,-(%sp)
move.l %d0,-(%sp)
jsr __divsi3
addq.l #8,%sp
rts
.size mydiv, .-mydiv
.align 2
.globl mydiv2
.type mydiv2, @function
mydiv2:
move.w 6(%sp),%d0
and.l #0xFFFF,%d0
divu.w 10(%sp),%d0
rts
.size mydiv2, .-mydiv2
.ident "GCC: (GNU) 7.2.0"
The hardware division is several times faster than divsi3. Further, I'm baffled
as to why gcc turns the unsigned division to signed, as udivsi3 would be faster
than divsi3.
More information about the Gcc-bugs
mailing list