<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - [gvn-hoist] miscompile"
   href="https://llvm.org/bugs/show_bug.cgi?id=29034">29034</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[gvn-hoist] miscompile
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Scalar Optimizations
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>zyfwong@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=16981" name="attach_16981" title="before opt -gvn-hoist">attachment 16981</a> <a href="attachment.cgi?id=16981&action=edit" title="before opt -gvn-hoist">[details]</a></span>
before opt -gvn-hoist

gvn-hoist seems to hoist a store before load:

the c code is something like:
void music_task(void *p)
{
    MUSIC_OP_API *mapi=((void*)0);
    dec_inf_t *dec_info=((void*)0);
    u32 err;
    tbool file_auto_next = 1;

    music_decoder_init(&mapi);

    while(1)
    {
        err =
music_play_api(mapi,DEV_SEL_CUR,0,PLAY_SPEC_FILE,&(mapi->dop_api->file_num));
        while(0 != err)
        {
            u32 status;
            switch(err)
            {
            case SUCC_MUSIC_START_DEC:
                err = 0;
                printf("s_num:%d\n",mapi->dop_api->file_num); /// <-------
after -gvn-hoist,   mapi->do_api->file_num will always be 1
                break;
            case FILE_OP_ERR_END_FILE:
                mapi->dop_api->file_num = 1;
                err =
music_play_api(mapi,DEV_SEL_NEXT,0,PLAY_FIRST_FILE,&(mapi->dop_api->file_num));
                break;
            case FILE_OP_ERR_PRE_FILE:
                mapi->dop_api->file_num = 1;
                err =
music_play_api(mapi,DEV_SEL_PREV,0,PLAY_LAST_FILE,&(mapi->dop_api->file_num));
                break;
            default:
                err = music_play_api(mapi,DEV_SEL_CUR,0,PLAY_NEXT_FILE,0);
                break;
            }
        }
    }
}</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>