<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/63227>63227</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [x86] unnecessary jmp to ret 
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          weiguozhi
      </td>
    </tr>
</table>

<pre>
    Compile the source code libc/src/string/memcmp.cpp on x86 with option O2/O3, I got

```
_ZN11__llvm_libc17inline_memcmp_x86EPKNS_3cpp4byteES3_m: # @_ZN11__llvm_libc17inline_memcmp_x86EPKNS_3cpp4byteES3_m
 .cfi_startproc
# %bb.0:                                # %entry
 cmpq    $3, %rdx
    ja  .LBB1_6
# %bb.1: # %entry
    leaq    .LJTI1_0(%rip), %rax
    movslq  (%rax,%rdx,4), %rcx
    addq    %rax, %rcx
    jmpq    *%rcx
.LBB1_22:
    xorl %eax, %eax
    jmp .LBB1_23                               //  can be replaced by retq
        ...
.LBB1_23:
        retq
 ...
```

Instruction "jmp   .LBB1_23" can be replaced by retq.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVNFuqzgQ_RrzMiqCMTjkgYc0LVJ3q3al7tO-IGOc4Mpgaps22a-_wuGmSa-uKl0LGaGZOefM8RjunNoPUpYkvyX5XcQn3xlbfki1n8z_nYoa0x7LrelHpSX4ToIzkxUShGklaNUIgpWzYfdWDXuCVS970Y-xGEcwAxwKBh_Kd2BGr8wAz0iweqYEt_AAe-NJckeSzbKzZHnCZ_3fU5rWtdbvfT1TpSs1aDXI-sRQHwp2_8_fTy81FeOYNUcv719o3RO6AYIUSJb8KUKgh1jsVO08t360RiwSZ2DMmyZOZp5v1pItB2-PC6jox7dTKAsmEMxte1iCAPDKAeLH29u0Zl8Z03Nn15AAoCUPqPHjX_8-pHVCsJiB1Uhw_ZOFX7D05t3pt1lFsYRwuyjBbXZRJC6KeNsu0peKXzJez81tLkOnfhAJ3XzmHozVoZMzlOTXUIsPSL91uSJYAQg-QCPBylFzIVtojmClf_vEDA7F8ZUoeiVqXhc15-Qvk3naHwbn7STCWBPEWTGcNRPE3wmKo7ak7ZqueSTLlBWM5ildsagrkbJVlghaNHnBC86KTO7WmKJo01Uj0iJSJSZIE5asEXOWshjznUxRsozhTmLakiyRPVc6nmc-NnYfKecmWTKKuIo0b6R24bIjDvIDQpAgznfflnPNTTPtHckSrZx3nyheeR3-EoeCkfwOpmGQQjrH7TEclTdzaxBNVped96ObbQ3nsle-m5pYmJ5gNeMtr5vRmlcpPMEqqHAEq6DyRwAAAP__7DlIMA">