<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 - Infinite loop in DAG combining"
   href="https://bugs.llvm.org/show_bug.cgi?id=40521">40521</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Infinite loop in DAG combining
          </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>enhancement
          </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>mikael.holmen@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=21403" name="attach_21403" title="reproducer">attachment 21403</a> <a href="attachment.cgi?id=21403&action=edit" title="reproducer">[details]</a></span>
reproducer

Reproduce with
 llc bbi-23735.ll -o -

With -debug we see some repeated printouts:

Combining: t28: ch = store<(store 5 into %ir.res2, align 8), trunc to i36>
t126:1, t129, FrameIndex:i64<1>, undef:i64

Combining: t126: i64,ch = load<(dereferenceable load 4 from %ir.f, align 8),
zext from i32> t0, FrameIndex:i64<0>, undef:i64

Combining: t129: i64 = and t127, Constant:i64<4095>
Creating new node: t130: i32 = truncate t126
Creating constant: t131: i32 = Constant<4095>
Creating new node: t132: i32 = srl t130, Constant:i8<15>
Creating new node: t133: i32 = and t132, Constant:i32<4095>
Creating new node: t134: i64 = zero_extend t133
 ... into: t134: i64 = zero_extend t133

Combining: t126: i64,ch = load<(dereferenceable load 4 from %ir.f, align 8),
zext from i32> t0, FrameIndex:i64<0>, undef:i64

Combining: t28: ch = store<(store 5 into %ir.res2, align 8), trunc to i36>
t126:1, t134, FrameIndex:i64<1>, undef:i64

Combining: t134: i64 = zero_extend t133

Combining: t133: i32 = and t132, Constant:i32<4095>

Combining: t131: i32 = Constant<4095>

Combining: t132: i32 = srl t130, Constant:i8<15>

Combining: t130: i32 = truncate t126
Creating new node: t135: i32,ch = load<(dereferenceable load 4 from %ir.f,
align 8)> t0, FrameIndex:i64<0>, undef:i64
 ... into: t135: i32,ch = load<(dereferenceable load 4 from %ir.f, align 8)>
t0, FrameIndex:i64<0>, undef:i64

Combining: t28: ch = store<(store 5 into %ir.res2, align 8), trunc to i36>
t135:1, t134, FrameIndex:i64<1>, undef:i64

Combining: t134: i64 = zero_extend t133
Creating new node: t136: i64,ch = load<(dereferenceable load 4 from %ir.f,
align 8), zext from i32> t0, FrameIndex:i64<0>, undef:i64
Creating new node: t137: i64 = srl t136, Constant:i8<15>
Creating constant: t138: i64 = Constant<4095>
Creating new node: t139: i64 = and t137, Constant:i64<4095>

Replacing.1 t134: i64 = zero_extend t133

With: t139: i64 = and t137, Constant:i64<4095>
 and 0 other values

Combining: t28: ch = store<(store 5 into %ir.res2, align 8), trunc to i36>
t136:1, t139, FrameIndex:i64<1>, undef:i64

Combining: t136: i64,ch = load<(dereferenceable load 4 from %ir.f, align 8),
zext from i32> t0, FrameIndex:i64<0>, undef:i64

Combining: t139: i64 = and t137, Constant:i64<4095>
Creating new node: t140: i32 = truncate t136
Creating constant: t141: i32 = Constant<4095>
Creating new node: t142: i32 = srl t140, Constant:i8<15>
Creating new node: t143: i32 = and t142, Constant:i32<4095>
Creating new node: t144: i64 = zero_extend t143
 ... into: t144: i64 = zero_extend t143

Combining: t136: i64,ch = load<(dereferenceable load 4 from %ir.f, align 8),
zext from i32> t0, FrameIndex:i64<0>, undef:i64

Combining: t28: ch = store<(store 5 into %ir.res2, align 8), trunc to i36>
t136:1, t144, FrameIndex:i64<1>, undef:i64


This starts happening with r329516 but I've no idea if that commit is really to
blame or if it just exposes some old problem.

r329516:
    [DAGCombiner] Fold (zext (and/or/xor (shl/shr (load x), cst), cst))

    In our real world application, we found the following optimization is
missed in DAGCombiner

    (zext (and/or/xor (shl/shr (load x), cst), cst)) -> (and/or/xor (shl/shr
(zextload x), (zext cst)), (zext cst))

    If the user of original zext is an add, it may enable further lea
optimization on x86.

    This patch add a new function CombineZExtLogicopShiftLoad to do this
optimization.

    Differential Revision: <a href="https://reviews.llvm.org/D44402">https://reviews.llvm.org/D44402</a></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>