<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 - Assertion `(LocalChanged || (RefHash == StructuralHash(F))) && "Pass modifies its input and doesn't report it."' for -gvn pass"
   href="https://bugs.llvm.org/show_bug.cgi?id=47378">47378</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Assertion `(LocalChanged || (RefHash == StructuralHash(F))) && "Pass modifies its input and doesn't report it."' for -gvn pass
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </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>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>new bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>david.stenberg@ericsson.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=23910" name="attach_23910" title="IR reproducer.">attachment 23910</a> <a href="attachment.cgi?id=23910&action=edit" title="IR reproducer.">[details]</a></span>
IR reproducer.

LLVM commit: 113861b444610aebd1c05760a3e0ee6284f42211

Requires an expensive checks build to reproduce.

$ opt -S -gvn gvn.ll
Pass modifies its input and doesn't report it: Global Value Numbering
Pass modifies its input and doesn't report it
UNREACHABLE executed at ../lib/IR/LegacyPassManager.cpp:1525!

Code change that the pass produces without the assertion enabled:

@@ -15,6 +18,7 @@
   %2 = load i16, i16* @b, align 1
   %inc = add nsw i16 %2, 1
   store i16 %inc, i16* @b, align 1
+  %.pre = trunc i32 %0 to i16
   br label %if.end

 if.else:                                          ; preds = %entry
@@ -23,10 +27,10 @@
   br label %if.end

 if.end:                                           ; preds = %if.else, %if.then
-  %3 = trunc i32 %0 to i16
-  %arrayidx = getelementptr inbounds [1 x i16], [1 x i16]* @c, i16 0, i16 %3
-  %4 = load i16, i16* %arrayidx, align 1
-  store i16 %4, i16* @b, align 1
+  %.pre-phi = phi i16 [ %conv, %if.else ], [ %.pre, %if.then ]
+  %arrayidx = getelementptr inbounds [1 x i16], [1 x i16]* @c, i16 0, i16
%.pre-phi
+  %3 = load i16, i16* %arrayidx, align 1
+  store i16 %3, i16* @b, align 1
   ret i16 undef
 }@@ -15,6 +18,7 @@
   %2 = load i16, i16* @b, align 1
   %inc = add nsw i16 %2, 1
   store i16 %inc, i16* @b, align 1
+  %.pre = trunc i32 %0 to i16
   br label %if.end

 if.else:                                          ; preds = %entry
@@ -23,10 +27,10 @@
   br label %if.end

 if.end:                                           ; preds = %if.else, %if.then
-  %3 = trunc i32 %0 to i16
-  %arrayidx = getelementptr inbounds [1 x i16], [1 x i16]* @c, i16 0, i16 %3
-  %4 = load i16, i16* %arrayidx, align 1
-  store i16 %4, i16* @b, align 1
+  %.pre-phi = phi i16 [ %conv, %if.else ], [ %.pre, %if.then ]
+  %arrayidx = getelementptr inbounds [1 x i16], [1 x i16]* @c, i16 0, i16
%.pre-phi
+  %3 = load i16, i16* %arrayidx, align 1
+  store i16 %3, i16* @b, align 1
   ret i16 undef
 }</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>