https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80929
Bug ID: 80929 Summary: [7/8 Regression] Division with constant no more optimized to mult highpart Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: gjl at gcc dot gnu.org Target Milestone: --- Since PR79665, division with known denominator are no more optimized to __umulhisi3 but transfomed to an expensive signed division instead. unsigned scale255 (unsigned val) { return val / 255; } $ avr-gcc -O2 -mmcu=atmega328 -S ... Reason is that PR79655 uses rtlanal.c::seq_cost() to compute the cost of (un)signed division, and seq_cost assumes anything that's not a single_set has the very low cost of 1. However avr BE, represents division as a PARALLEL, not as a single_set, i.e. something like: (insn 14 13 0 (parallel [ (set (reg:HI 52) (div:HI (reg:HI 47) (reg:HI 54))) (set (reg:HI 53) (mod:HI (reg:HI 47) (reg:HI 54))) (clobber (reg:QI 21 r21)) (clobber (reg:HI 22 r22)) (clobber (reg:HI 24 r24)) (clobber (reg:HI 26 r26)) ]) "scale.c":7 -1 (nil))