[Bug target/86011] Inefficient code generated for ldivmod with constant value
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86011 Andrew Pinski changed: What|Removed |Added Status|NEW |RESOLVED Target Milestone|--- |11.0 Resolution|--- |FIXED --- Comment #4 from Andrew Pinski --- Fixed in GCC 11: lsrsr1, r2, #30 push{r4, lr} orr r1, r1, r3, lsl #2 bic lr, r1, #-1073741824 bic r1, r2, #-1073741824 add r1, r1, lr asrsr4, r3, #31 add r3, r1, r3, lsr #28 and r1, r4, #137 add r3, r3, r1 movwr1, #57025 movtr1, 13617 bic r4, r4, #75 umull lr, r1, r1, r3 mov lr, #77 lsrsr1, r1, #4 mls r3, lr, r1, r3 movwr1, #14469 movtr1, 16171 add r3, r3, r4 str r3, [r0, #4] subsr2, r2, r3 umull r2, r1, r2, r1 str r2, [r0] pop {r4, pc} For: #define N 7723 struct foo { long a, b; }; struct foo test(long long x) { return (struct foo){x / N, x % N}; } GCC 11+ Produces: push{r4, lr} mov r4, r0 mov r1, r3 mov r0, r2 movsr3, #0 movwr2, #7723 bl __aeabi_ldivmod strdr0, r2, [r4] mov r0, r4 pop {r4, pc} Which is exactly what you want too.
[Bug target/86011] Inefficient code generated for ldivmod with constant value
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86011 Patrick Oppenlander changed: What|Removed |Added Version|8.1.0 |9.2.0 --- Comment #3 from Patrick Oppenlander --- Still present in 9.2.0.
[Bug target/86011] Inefficient code generated for ldivmod with constant value
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86011 Steven Bosscher changed: What|Removed |Added Status|WAITING |NEW
[Bug target/86011] Inefficient code generated for ldivmod with constant value
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86011 --- Comment #2 from Patrick Oppenlander --- Sure, # cat test.c struct foo { long a, b; }; struct foo test(long long x) { return (struct foo){x / 77, x % 77}; } # gcc --version gcc (GCC) 8.1.0 Copyright (C) 2018 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # gcc -c -O2 test.c # objdump -d test.o test.o: file format elf32-littlearm Disassembly of section .text: : 0: e92d40d0push{r4, r6, r7, lr} 4: e1a06002mov r6, r2 8: e1a07003mov r7, r3 c: e1a04000mov r4, r0 10: e3a0204dmov r2, #77 ; 0x4d 14: e3a03000mov r3, #0 18: e1a6mov r0, r6 1c: e1a01007mov r1, r7 20: ebfebl 0 <__aeabi_ldivmod> 24: e1a01007mov r1, r7 28: e3a0204dmov r2, #77 ; 0x4d 2c: e3a03000mov r3, #0 30: e584str r0, [r4] 34: e1a6mov r0, r6 38: ebfebl 0 <__aeabi_ldivmod> 3c: e1a4mov r0, r4 40: e5842004str r2, [r4, #4] 44: e8bd80d0pop {r4, r6, r7, pc} Looks like the same problem is still there.
[Bug target/86011] Inefficient code generated for ldivmod with constant value
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86011 Richard Biener changed: What|Removed |Added Keywords||missed-optimization Target||arm Status|UNCONFIRMED |WAITING Last reconfirmed||2018-06-01 Component|other |target Ever confirmed|0 |1 --- Comment #1 from Richard Biener --- I think this was fixed with GCC 8. Can you check?