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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Target|arm                         |arm, x86_64
             Status|ASSIGNED                    |NEW
            Summary|GCC10 produces bigger asm   |GCC10 produces bigger asm
                   |for simple switch than GCC7 |for simple switch than GCC7
                   |- cortexM4                  |- cortexM4 since
                   |                            |r8-2701-g9dc3d6a96167b4c8

--- Comment #4 from Martin Liška <marxin at gcc dot gnu.org> ---
I can confirm the minor regression that started with r8-2701-g9dc3d6a96167b4c8
(aka switch lowering made on the TREE level).

One can also see it on x86_64-linux:

gcc-7
switchFunction:
.LFB0:
        .cfi_startproc
        movl    %edi, %eax
        cmpl    $2, %edi
        movl    $-1, %edx
        cmovnb  %edx, %eax
        ret
        .cfi_endproc

gcc-12
switchFunction:
.LFB0:
        .cfi_startproc
        movl    %edi, %eax
        testl   %edi, %edi
        je      .L2
        cmpl    $1, %edi
        movl    $-1, %edx
        cmovne  %edx, %eax

Note the test-case is quite special as the shorter version does:

int switchFunction(int foo) {
  switch (foo) {
  case 0:
    return foo;
  case 1:
    return foo;
  default:
    return -1;
  }
}

that's trick that's used.

Reply via email to