<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 - [SelectionDAG] Assertion "Wrong topological sorting" failed."
   href="https://bugs.llvm.org/show_bug.cgi?id=41256">41256</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[SelectionDAG]  Assertion "Wrong topological sorting" failed.
          </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>Backend: SystemZ
          </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=21685" name="attach_21685" title="reduced testcase">attachment 21685</a> <a href="attachment.cgi?id=21685&action=edit" title="reduced testcase">[details]</a></span>
reduced testcase

tryFoldLoadStoreIntoMemOperand() calls isFusableLoadOpStorePattern() on this
DAG:

SelectionDAG has 30 nodes:
  t0: ch = EntryToken
  t44: i64 = SystemZISD::PCREL_WRAPPER TargetGlobalAddress:i64<i64* @g_672> 0
  t9: i64,ch = load<(dereferenceable load 8 from @g_672, !tbaa !9)> t0, t44,
undef:i64
  t36: i64,i32 = SystemZISD::UADDO t9, Constant:i64<1>
    t39: i32 = SystemZISD::SELECT_CCMASK Constant:i32<1>, Constant:i32<0>,
Constant:i32<15>, Constant:i32<3>, t36:1
    t2: i64,ch = CopyFromReg t0, Register:i64 %0
  t31: i32,ch = CLMux<Mem:(dereferenceable load 4 from %ir.mat_bitcast, align
1, !tbaa !8)> t39, t2, TargetConstant:i64<16>, Register:i64 $noreg, t0
  t45: i32 = TargetConstant<1>
        t12: ch = TokenFactor t31:1, t9:1
      t13: ch = store<(store 8 into @g_672, !tbaa !9)> t12, t36, t44, undef:i64
          t50: ch,glue = CopyToReg t0, Register:i32 $cc, t31
        t35: i32 = LOCHIMux Constant:i32<0>, TargetConstant:i64<1>,
TargetConstant:i32<14>, TargetConstant:i32<2>, t50:1
      t21: ch = STRL<Mem:(store 4 into @g_295, !tbaa !10)> t35,
TargetGlobalAddress:i64<i32* @g_295> 0, t31:1
    t22: ch = TokenFactor t13, t21
  t20: ch = Return t22

Note that there t31 is a memory access that is chained in between the load and
store: t13 -> t12 -> t31 -> t39 -> t36 -> t9

isFusableLoadOpStorePattern() fails to return false here and as a result a
cycle will be introduced in the graph once the ALGSI has been formed.

It would be nice to detect this with IsReachable() calls to prove that there is
no user of the OF result that would cause a cycle. Unfortunately it does not
seem that the TopologicalSorting is available until scheduling.

Perhaps it would be easier to do this folding after instruction selection on
the MBB?

bin/llc -mtriple=s390x-linux-gnu -mcpu=z13 tc_topo2.ll -disable-basicaa
-enable-tbaa=false -consthoist-gep -o out.s

(I have one more test case that does not disable AA, but it has a much bigger
DAG even when reduced.)</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>