[Bug middle-end/91174] New: Suboptimal code for arithmetic with bool

antoshkka at gmail dot com gcc-bugzilla@gcc.gnu.org
Mon Jul 15 14:28:00 GMT 2019


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91174

            Bug ID: 91174
           Summary: Suboptimal code for arithmetic with bool
           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: ---

Consider the example:

int test (bool x) {
    return '0' + x;
}


For the above snippet the following suboptimal assembly is generated:


test(bool):
  movzx eax, dil
  add eax, 48
  ret


More efficient assembly would be:

test(bool):
  lea eax, [rdi + 48]
  ret


More information about the Gcc-bugs mailing list