https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91709
Bug ID: 91709 Summary: Missed optimization for multiplication on 1.5 and 1.25 Product: gcc Version: 10.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: antoshkka at gmail dot com Target Milestone: --- On x86_32 for any number X of type (unsigned, unsigned short, unsigned char) multiplication by 1.5 with a conversion back to unsigned with any rounding mode produces the exactly same result as if X + (X >> 1). Same holds for 1.25: unsigned(X * 1.25) == unsigned(X + (X >> 2)) The above transformation allows to emit a short code without floating point computations: test2(unsigned int): mov eax, edi shr eax add eax, edi ret Instead of: test(unsigned int): movl %edi, %edi pxor %xmm0, %xmm0 cvtsi2sdq %rdi, %xmm0 mulsd .LC0(%rip), %xmm0 cvttsd2siq %xmm0, %rax ret .LC0: .long 0 .long 1073217536