64 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py2 3; We run -passes=indvars before -passes=simple-loop-unswitch to compute SCEV exit counts before4; running -simple-loop-unswitch.5; RUN: opt -passes=indvars,simple-loop-unswitch -S %s -verify-scev | FileCheck %s6 7; Test for PR43972.8 9; We have a 3 nested loops (l1 <- l2 <- l3). %for.cond.5 is the exit block of10; l3 and the loop for it is l2. But it is also the exiting block of l1. That11; means we have to invalidate l1 to preserve SCEV.12 13define void @f() {14; CHECK-LABEL: @f(15; CHECK-NEXT: entry:16; CHECK-NEXT: [[LNOT:%.*]] = xor i1 undef, true17; CHECK-NEXT: br label [[FOR_COND:%.*]]18; CHECK: for.cond.loopexit:19; CHECK-NEXT: br label [[FOR_COND]]20; CHECK: for.cond:21; CHECK-NEXT: br label [[FOR_BODY:%.*]]22; CHECK: for.cond1:23; CHECK-NEXT: br i1 true, label [[FOR_BODY]], label [[FOR_COND_LOOPEXIT:%.*]]24; CHECK: for.body:25; CHECK-NEXT: br i1 [[LNOT]], label [[FOR_BODY_SPLIT:%.*]], label [[FOR_COND5_SPLIT:%.*]]26; CHECK: for.body.split:27; CHECK-NEXT: br label [[LAND_RHS:%.*]]28; CHECK: for.cond2:29; CHECK-NEXT: br i1 true, label [[LAND_RHS]], label [[FOR_COND5:%.*]]30; CHECK: land.rhs:31; CHECK-NEXT: br label [[FOR_COND2:%.*]]32; CHECK: for.cond5:33; CHECK-NEXT: br label [[FOR_COND5_SPLIT]]34; CHECK: for.cond5.split:35; CHECK-NEXT: br i1 true, label [[FOR_BODY7:%.*]], label [[FOR_COND1:%.*]]36; CHECK: for.body7:37; CHECK-NEXT: ret void38;39entry:40 %lnot = xor i1 undef, true41 br label %for.cond42 43for.cond: ; preds = %for.cond1, %entry44 br label %for.body45 46for.cond1: ; preds = %for.cond547 br i1 true, label %for.body, label %for.cond48 49for.body: ; preds = %for.cond1, %for.cond50 br label %land.rhs51 52for.cond2: ; preds = %land.rhs53 br i1 true, label %land.rhs, label %for.cond554 55land.rhs: ; preds = %for.cond2, %for.body56 br i1 %lnot, label %for.cond2, label %for.cond557 58for.cond5: ; preds = %land.rhs, %for.cond259 br i1 true, label %for.body7, label %for.cond160 61for.body7: ; preds = %for.cond562 ret void63}64