<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 - JumpThreading create instruction that reference its own value"
   href="https://bugs.llvm.org/show_bug.cgi?id=37745">37745</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>JumpThreading create instruction that reference its own value
          </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>karl-johan.karlsson@ericsson.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=20412" name="attach_20412" title="Reproducer: opt -jump-threading -verify-each -S -mtriple=x86_64--">attachment 20412</a> <a href="attachment.cgi?id=20412&action=edit" title="Reproducer: opt -jump-threading -verify-each -S -mtriple=x86_64--">[details]</a></span>
Reproducer: opt -jump-threading -verify-each -S -mtriple=x86_64--

$ ./opt -jump-threading -verify-each -S -mtriple=x86_64-- -o -
./jumpthreading.ll -print-after-all -print-before-all
*** IR Dump Before Jump Threading ***
define void @f1() {
entry:
  br i1 false, label %lbl1, label %if.end

lbl1:                                             ; preds = %if.end, %entry
  %p1.addr.0 = phi i16 [ undef, %entry ], [ %inc, %if.end ]
  br label %if.end

if.end:                                           ; preds = %lbl1, %entry
  %p1.addr.1 = phi i16 [ %p1.addr.0, %lbl1 ], [ undef, %entry ]
  %inc = add nsw i16 %p1.addr.1, 1
  %tobool = icmp ne i16 %inc, 0
  br i1 %tobool, label %if.end4, label %lbl1

if.end4:                                          ; preds = %if.end
  ret void
}
*** IR Dump After Jump Threading ***
define void @f1() {
if.end:
  %inc = add nsw i16 undef, 1
  %tobool = icmp ne i16 %inc, 0
  br i1 %tobool, label %if.end4, label %if.end.thread

if.end.thread:                                    ; preds = %if.end
  %inc1 = add nsw i16 %inc1, 1
  br label %if.end4

if.end4:                                          ; preds = %if.end.thread,
%if.end
  ret void
}
*** IR Dump Before Module Verifier ***
define void @f1() {
if.end:
  %inc = add nsw i16 undef, 1
  %tobool = icmp ne i16 %inc, 0
  br i1 %tobool, label %if.end4, label %if.end.thread

if.end.thread:                                    ; preds = %if.end
  %inc1 = add nsw i16 %inc1, 1
  br label %if.end4

if.end4:                                          ; preds = %if.end.thread,
%if.end
  ret void
}
Only PHI nodes may reference their own value!
  %inc1 = add nsw i16 %inc1, 1
LLVM ERROR: Broken function found, compilation aborted!</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>