https://bugs.llvm.org/show_bug.cgi?id=41256

            Bug ID: 41256
           Summary: [SelectionDAG]  Assertion "Wrong topological sorting"
                    failed.
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: SystemZ
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]

Created attachment 21685
  --> https://bugs.llvm.org/attachment.cgi?id=21685&action=edit
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.)

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to