[llvm-bugs] [Bug 50442] New: [indvars] rewriteLoopExitValues cause run stuck

via llvm-bugs llvm-bugs at lists.llvm.org
Sat May 22 02:19:13 PDT 2021


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

            Bug ID: 50442
           Summary: [indvars] rewriteLoopExitValues cause run stuck
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Loop Optimizer
          Assignee: unassignedbugs at nondot.org
          Reporter: guopeilin1 at huawei.com
                CC: llvm-bugs at lists.llvm.org

Created attachment 24882
  --> https://bugs.llvm.org/attachment.cgi?id=24882&action=edit
A test case file

The program will run stuck when using opt -indvars test-case.ll -S.

The bug seems caused by reWriteLoopExitValues optimization. After this
optimization, the exit value ( %add.i.2. i) becomes extremely long and
complicated. Thus cost plenty of time for printing this instruction into the
screen.

And even without flag -S, I still believe that ISel will meet a segment fault
because long instruction with plenty of operands will run out the stack when
building SlectionDAG for IR.


The test-case.ll
%struct.ad = type { i8 }
%struct.ae = type { %struct.ad }
@aj = dso_local global [5 x [0 x [5 x %struct.ad]]] zeroinitializer, align 1
@al = dso_local global %struct.ae zeroinitializer, align 1

define dso_local i32 @_Z2aqv() local_unnamed_addr {
entry:
  br label %for.cond4.preheader.i

for.cond4.preheader.i:                            ; preds =
%for.cond4.preheader.i, %entry
  %av.addr.04.i = phi i32 [ 0, %entry ], [ %sub.i.2.i, %for.cond4.preheader.i ]
  %aw.sroa.0.03.i = phi i32 [ 0, %entry ], [ %dec.i, %for.cond4.preheader.i ]
  %add.i.i = add nsw i32 %av.addr.04.i, zext (i1 icmp eq (%struct.ad* bitcast
(i8* getelementptr inbounds ([5 x [0 x [5 x %struct.ad]]], [5 x [0 x [5 x
%struct.ad]]]* @aj, i64 0, i64 0, i64 9, i64 1, i32 0) to %struct.ad*),
%struct.ad* getelementptr inbounds (%struct.ae, %struct.ae* @al, i64 0, i32 0))
to i32)
  %cmp.i.i = icmp sgt i32 %av.addr.04.i, 7
  %add.i.i.op = shl i32 %add.i.i, 16
  %add.i.i.op.op = ashr i32 %add.i.i.op, 31
  %add.i.i.op.op.op = xor i32 %add.i.i.op.op, -1
  %sext.i.lobit.not = select i1 %cmp.i.i, i32 -1, i32 %add.i.i.op.op.op
  %sub.i.i = add i32 %sext.i.lobit.not, %av.addr.04.i
  %add.i.1.i = add nsw i32 %sub.i.i, zext (i1 icmp eq (%struct.ad* bitcast (i8*
getelementptr inbounds ([5 x [0 x [5 x %struct.ad]]], [5 x [0 x [5 x
%struct.ad]]]* @aj, i64 0, i64 0, i64 9, i64 1, i32 0) to %struct.ad*),
%struct.ad* getelementptr inbounds (%struct.ae, %struct.ae* @al, i64 0, i32 0))
to i32)
  %cmp.i.1.i = icmp sgt i32 %sub.i.i, 7
  %add.i.1.i.op = shl i32 %add.i.1.i, 16
  %add.i.1.i.op.op = ashr i32 %add.i.1.i.op, 31
  %add.i.1.i.op.op.op = xor i32 %add.i.1.i.op.op, -1
  %sext.1.i.lobit.not = select i1 %cmp.i.1.i, i32 -1, i32 %add.i.1.i.op.op.op
  %sub.i.1.i = add i32 %sext.1.i.lobit.not, %sub.i.i
  %add.i.2.i = add nsw i32 %sub.i.1.i, zext (i1 icmp eq (%struct.ad* bitcast
(i8* getelementptr inbounds ([5 x [0 x [5 x %struct.ad]]], [5 x [0 x [5 x
%struct.ad]]]* @aj, i64 0, i64 0, i64 9, i64 1, i32 0) to %struct.ad*),
%struct.ad* getelementptr inbounds (%struct.ae, %struct.ae* @al, i64 0, i32 0))
to i32)
  %cmp.i.2.i = icmp sgt i32 %sub.i.1.i, 7
  %add.i.2.i.op = shl i32 %add.i.2.i, 16
  %add.i.2.i.op.op = ashr i32 %add.i.2.i.op, 31
  %add.i.2.i.op.op.op = xor i32 %add.i.2.i.op.op, -1
  %sext.2.i.lobit.not = select i1 %cmp.i.2.i, i32 -1, i32 %add.i.2.i.op.op.op
  %sub.i.2.i = add i32 %sext.2.i.lobit.not, %sub.i.1.i
  %dec.i = add nsw i32 %aw.sroa.0.03.i, -1
  %cmp.i = icmp sgt i32 %aw.sroa.0.03.i, -5
  br i1 %cmp.i, label %for.cond4.preheader.i, label %_ZL2apiPiiS_.exit

_ZL2apiPiiS_.exit:                                ; preds =
%for.cond4.preheader.i
  %add.i.2.i.lcssa = phi i32 [ %add.i.2.i, %for.cond4.preheader.i ]
  %conv8.i = sext i32 %add.i.2.i.lcssa to i64
  ret i32 0
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210522/40503e32/attachment-0001.html>


More information about the llvm-bugs mailing list