llvm/llvm/test/Transforms/LoopStrengthReduce/2011-12-19-PostincQuadratic.ll

; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2
; RUN: opt -loop-reduce -S < %s | FileCheck %s
;
; PR11571: handle a postinc user outside of for.body7 that requires
; recursive expansion of a quadratic recurrence within for.body7. LSR
; needs to forget that for.body7 is a postinc loop during expansion.

target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32-S128"
target triple = "i386-unknown-freebsd10.0"

@b = external global [121 x i32]

define void @vb() nounwind {
; CHECK-LABEL: define void @vb
; CHECK-SAME: () #[[ATTR0:[0-9]+]] {
; CHECK-NEXT:  for.cond.preheader:
; CHECK-NEXT:    br label [[FOR_BODY7:%.*]]
; CHECK:       for.body7:
; CHECK-NEXT:    [[LSR_IV1:%.*]] = phi ptr [ [[SCEVGEP:%.*]], [[FOR_BODY7]] ], [ getelementptr inbounds nuw (i8, ptr @b, i32 4), [[FOR_COND_PREHEADER:%.*]] ]
; CHECK-NEXT:    [[LSR_IV:%.*]] = phi i32 [ [[LSR_IV_NEXT:%.*]], [[FOR_BODY7]] ], [ 8, [[FOR_COND_PREHEADER]] ]
; CHECK-NEXT:    [[INDVARS_IV77:%.*]] = phi i32 [ [[INDVARS_IV_NEXT78:%.*]], [[FOR_BODY7]] ], [ 1, [[FOR_COND_PREHEADER]] ]
; CHECK-NEXT:    [[INDVARS_IV_NEXT78]] = add i32 [[INDVARS_IV77]], 1
; CHECK-NEXT:    [[LSR_IV_NEXT]] = add nuw nsw i32 [[LSR_IV]], 4
; CHECK-NEXT:    [[SCEVGEP]] = getelementptr i8, ptr [[LSR_IV1]], i32 [[LSR_IV]]
; CHECK-NEXT:    br i1 true, label [[FOR_BODY43_PREHEADER:%.*]], label [[FOR_BODY7]]
; CHECK:       for.body43.preheader:
; CHECK-NEXT:    br label [[FOR_BODY43:%.*]]
; CHECK:       for.body43:
; CHECK-NEXT:    [[LSR_IV2:%.*]] = phi ptr [ [[LSR_IV1]], [[FOR_BODY43_PREHEADER]] ], [ [[SCEVGEP3:%.*]], [[FOR_BODY43]] ]
; CHECK-NEXT:    [[T2:%.*]] = load i32, ptr [[LSR_IV2]], align 4
; CHECK-NEXT:    [[SCEVGEP3]] = getelementptr i8, ptr [[LSR_IV2]], i32 4
; CHECK-NEXT:    br label [[FOR_BODY43]]
;
for.cond.preheader:
  br label %for.body7

for.body7:
  %indvars.iv77 = phi i32 [ %indvars.iv.next78, %for.body7 ], [ 1, %for.cond.preheader ]
  %bf.072 = phi i32 [ %t1, %for.body7 ], [ 0, %for.cond.preheader ]
  %t1 = add i32 %bf.072, %indvars.iv77
  %indvars.iv.next78 = add i32 %indvars.iv77, 1
  br i1 undef, label %for.body43, label %for.body7

for.body43:
  %bf.459 = phi i32 [ %inc44, %for.body43 ], [ %t1, %for.body7 ]
  %inc44 = add nsw i32 %bf.459, 1
  %arrayidx45 = getelementptr inbounds [121 x i32], ptr @b, i32 0, i32 %bf.459
  %t2 = load i32, ptr %arrayidx45, align 4
  br label %for.body43
}