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

    <tr>
        <th>Summary</th>
        <td>
            condition jump instruction seems lost when optimization opened with -O1 or -O2 or -Oz
        </td>
    </tr>

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

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

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

<pre>
    ###  when i use below command to compile ffmpeg4.3.1 libavformat/utils.c with clang14 on Macmini M1 MacOS14.3.1:
`
/opt/homebrew/opt/llvm@14/bin/clang -I. -I./ --sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.2.sdk -D_ISOC99_SOURCE -D_LARGEFILE_SOURCE -I./compat/dispatch_semaphore -DPIC -DZLIB_CONST -DHAVE_AV_CONFIG_H -DBUILDING_avformat -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.2.sdk -arch arm64 -mios-version-min=11.0 -no-canonical-prefixes -Wno-invalid-command-line-argument -Wno-unused-command-line-argument -funwind-tables -fstack-protector-strong -fno-addrsig -Werror=return-type -Werror=int-to-pointer-cast -Werror=implicit-function-declaration -fPIC -DTARGET_OS_IPHONE=1 -Wall -pipe -std=c99 -ffast-math -g -O0 -DDEBUG_ENABLE -I/Users/yue/gitlab/libaveditor_6/buildbin_ios/tmp/arm64/include -std=c11 -Werror=partial-availability -fomit-frame-pointer -fPIC -pthread  -DX264_API_IMPORTS -I/opt/homebrew/Cellar/x264/r3108/include -ggdb -Wdeclaration-after-statement -Wall -Wdisabled-optimization -Wpointer-arith -Wredundant-decls -Wwrite-strings -Wtype-limits -Wundef -Wmissing-prototypes -Wno-pointer-to-int-cast -Wstrict-prototypes -Wempty-body -Wno-parentheses -Wno-switch -Wno-format-zero-length -Wno-pointer-sign -Wno-unused-const-variable -Wno-bool-operation -Wno-char-subscripts -Oz -fno-math-errno -fno-signed-zeros -mstack-alignment=16 -Qunused-arguments -Werror=implicit-function-declaration -Werror=missing-prototypes -Werror=return-type  -MMD -MF libavformat/utils.d -MT libavformat/utils.o -c -o libavformat/utils.o libavformat/utils.c
`
### then i disassembly like below:
`/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/objdump -S libavformat/utils.o > utils14.txt`

### i found  code "if (st->index_entries) {" in function "ff_seek_frame_binary" compiled like below, when i run to here, it always crash:
;     av_log(s, AV_LOG_TRACE, "read_seek: %d %s\n", stream_index, av_ts2str(target_ts));
    2b00: 4f00e400      movi.16b        v0, #0
    2b04: ad0403e0      stp     q0, q0, [sp, #128]
    2b08: 910203f4      add     x20, sp, #128
    2b0c: 910203e0      add     x0, sp, #128
    2b10: aa0203e1      mov     x1, x2
    2b14: 94000000      bl      0x2b14 <_ff_seek_frame_binary+0x5c>
    2b18: a90053f7      stp     x23, x20, [sp]
    2b1c: 90000002      adrp    x2, 0x2000 <_ff_seek_frame_binary+0x64>
    2b20: 91000042      add     x2, x2, #0
    2b24: 94000000      bl      0x2b24 <_ff_seek_frame_binary+0x6c>
;     st = s->streams[stream_index];
    2b28: f9401a68      ldr     x8, [x19, #48]
    2b2c: f8775914      ldr     x20, [x8, w23, uxtw  #3]
**;     if (st->index_entries) {
    2b30: f940e69a      ldr     x26, [x20, #456]**
;                                           flags | AVSEEK_FLAG_BACKWARD);
    2b34: 320002c2      orr     w2, w22, #0x1
    2b38: 94000000      bl      0x2b38 <_ff_seek_frame_binary+0x80>
;         index = FFMAX(index, 0);
    2b3c: 0aa07c08      bic     w8, w0, w0, asr #31
;         if (e->timestamp <= target_ts || e->pos == e->min_distance) {
    2b40: 52800309      mov     w9, #24
    2b44: 9ba96909      umaddl  x9, w8, w9, x26
    2b48: a9406139      ldp     x25, x24, [x9]
    2b4c: eb15031f      cmp     x24, x21
    2b50: 540000cd      b.le    0x2b68 <_ff_seek_frame_binary+0xb0>
    2b54: 52800309      mov     w9, #24
;         if (e->timestamp <= target_ts || e->pos == e->min_distance) {

### but when i use clang13 with same compile command , it generate code below:
;     av_log(s, AV_LOG_TRACE, "read_seek: %d %s\n", stream_index, av_ts2str(target_ts));
    2b14: 4f00e400      movi.16b        v0, #0
    2b18: ad0383e0      stp     q0, q0, [sp, #112]
    2b1c: 9101c3f4      add     x20, sp, #112
    2b20: 9101c3e0      add     x0, sp, #112
    2b24: aa0203e1      mov     x1, x2
    2b28: 94000000      bl      0x2b28 <_ff_seek_frame_binary+0x58>
    2b2c: a90053f7      stp     x23, x20, [sp]
    2b30: 90000002      adrp    x2, 0x2000 <_ff_seek_frame_binary+0x60>
    2b34: 91000042      add     x2, x2, #0
    2b38: 94000000      bl      0x2b38 <_ff_seek_frame_binary+0x68>
;     st = s->streams[stream_index];
    2b3c: f9401a68      ldr     x8, [x19, #48]
    2b40: f8775914      ldr     x20, [x8, w23, uxtw  #3]
**;     if (st->index_entries) {
    2b44: f940e69a      ldr     x26, [x20, #456]
    2b48: b400033a      cbz     x26, 0x2bac <_ff_seek_frame_binary+0xdc>**
;                                           flags | AVSEEK_FLAG_BACKWARD);
    2b4c: 320002c2      orr     w2, w22, #0x1
    2b50: 94000000      bl      0x2b50 <_ff_seek_frame_binary+0x80>
;         index = FFMAX(index, 0);
    2b54: 0aa07c08      bic     w8, w0, w0, asr #31
;         if (e->timestamp <= target_ts || e->pos == e->min_distance) {

### some one can help me found if my compile command somewhere error
[utils.zip](https://github.com/llvm/llvm-project/files/14383601/utils.zip)

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMWd1y27YSfhr4BgMNCFIyeeELyZJST-0oJ3bqzrnhgCQooSEBHgC05Dz9mSVI_cWx67bTVqPIIold7H777Y8Qbq1cKyGu0HiGxvML3rqNNlcbLkuh1oVQ64tMF89XiIX-jfF2IxSWuLUCZ6LSW5zruuaqwE7D10Z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