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

Reply via email to