<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </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 - [MachineCopyPropagagation] Incorrect dead flag survives"
   href="https://bugs.llvm.org/show_bug.cgi?id=33037">33037</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[MachineCopyPropagagation]  Incorrect dead flag survives
          </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>Common Code Generator Code
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>paulsson@linux.vnet.ibm.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=18438" name="attach_18438" title="reduced testcase">attachment 18438</a> <a href="attachment.cgi?id=18438&action=edit" title="reduced testcase">[details]</a></span>
reduced testcase

In this MBB:

BB#0: derived from LLVM BB %BB
        %V0<def> = VGBM 0
        %V1<def,dead> = COPY %V0
        %V1<def> = COPY %V0
        %V1<def,tied1> = VLEIH %V1<kill,tied0>, 0, 1
        %V0<def> = VCEQH %V1<kill>, %V0<kill>
        %R1D<def> = LARL <cp#0>
        %V1<def> = VL %R1D<kill>, 0, %noreg; mem:LD16[ConstantPool](align=8)
        %V0<def,dead> = VPERM %V0<kill>, %V0<undef>, %V1<kill>

, the first COPY of %V0 to %V1 has a dead flag, while the second one doesn't.

The optimization seems to think the second COPY is redundant, and calls
eraseIfRedundant(). Afterwards, this results in:

        %V1<def,dead> = COPY %V0
        %V1<def,tied1> = VLEIH %V1<kill,tied0>, 0, 1

*** Bad machine code: Using an undefined physical register ***
- function:    autogen_SD11756
- basic block: BB#0 BB (0x3c90be8)
- instruction: %V1<def,tied1> = VLEIH
- operand 1:   %V1<kill,tied0>

Somehow, the dead flag should have been removed.

Run line: llc -O3 -mtriple=s390x-linux-gnu -mcpu=z13 -verify-machineinstrs
-disable-cgp -pre-RA-sched=source -disable-machine-dce
-join-liveintervals=false  -o /dev/null ./tc_mcp_undefphysreg.ll</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>