llvm.org GIT mirror llvm / 2a7fbb1
[LoopReroll] Relax some assumptions a little. We won't find a root with index zero in any loop that we are able to reroll. However, we may find one in a non-rerollable loop, so bail gracefully instead of failing hard. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229406 91177308-0d34-0410-b5e6-96231b3b80d8 James Molloy 4 years ago
2 changed file(s) with 36 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
718718
719719 if (Roots.empty())
720720 return false;
721
722 assert(Roots.find(0) == Roots.end() && "Didn't expect a zero index!");
723721
724722 // If we found non-loop-inc, non-root users of Base, assume they are
725723 // for the zeroth root index. This is because "add %a, 0" gets optimized
726724 // away.
727 if (BaseUsers.size())
725 if (BaseUsers.size()) {
726 if (Roots.find(0) != Roots.end()) {
727 DEBUG(dbgs() << "LRR: Multiple roots found for base - aborting!\n");
728 return false;
729 }
728730 Roots[0] = Base;
731 }
729732
730733 // Calculate the number of users of the base, or lowest indexed, iteration.
731734 unsigned NumBaseUses = BaseUsers.size();
544544 ret void
545545 }
546546
547 %struct.s = type { i32, i32 }
548
549 ; Function Attrs: nounwind uwtable
550 define void @gep1(%struct.s* nocapture %x) #0 {
551 entry:
552 %call = tail call i32 @foo(i32 0) #1
553 br label %for.body
554
555 for.body: ; preds = %for.body, %entry
556 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
557 %0 = mul nsw i64 %indvars.iv, 3
558 %arrayidx = getelementptr inbounds %struct.s* %x, i64 %0, i32 0
559 store i32 %call, i32* %arrayidx, align 4
560 %1 = add nsw i64 %0, 1
561 %arrayidx4 = getelementptr inbounds %struct.s* %x, i64 %1, i32 0
562 store i32 %call, i32* %arrayidx4, align 4
563 %2 = add nsw i64 %0, 2
564 %arrayidx9 = getelementptr inbounds %struct.s* %x, i64 %2, i32 0
565 store i32 %call, i32* %arrayidx9, align 4
566 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
567 %exitcond = icmp eq i64 %indvars.iv.next, 500
568 br i1 %exitcond, label %for.end, label %for.body
569
570 ; CHECK-LABEL: @gep1
571 ; This test is a crash test only.
572 ; CHECK: ret
573 for.end: ; preds = %for.body
574 ret void
575 }
576
547577
548578 attributes #0 = { nounwind uwtable }
549579 attributes #1 = { nounwind }