1*9880d681SAndroid Build Coastguard Worker; REQUIRES: asserts 2*9880d681SAndroid Build Coastguard Worker; RUN: opt -loop-unswitch -disable-output -stats -info-output-file - < %s | FileCheck --check-prefix=STATS %s 3*9880d681SAndroid Build Coastguard Worker; RUN: opt -loop-unswitch -simplifycfg -S < %s | FileCheck %s 4*9880d681SAndroid Build Coastguard Worker; PR5373 5*9880d681SAndroid Build Coastguard Worker 6*9880d681SAndroid Build Coastguard Worker; Loop unswitching shouldn't trivially unswitch the true case of condition %a 7*9880d681SAndroid Build Coastguard Worker; in the code here because it leads to an infinite loop. While this doesn't 8*9880d681SAndroid Build Coastguard Worker; contain any instructions with side effects, it's still a kind of side effect. 9*9880d681SAndroid Build Coastguard Worker; It can trivially unswitch on the false cas of condition %a though. 10*9880d681SAndroid Build Coastguard Worker 11*9880d681SAndroid Build Coastguard Worker; STATS: 2 loop-unswitch - Number of branches unswitched 12*9880d681SAndroid Build Coastguard Worker; STATS: 2 loop-unswitch - Number of unswitches that are trivial 13*9880d681SAndroid Build Coastguard Worker 14*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: @func_16( 15*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: entry: 16*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: br i1 %a, label %entry.split, label %abort0.split 17*9880d681SAndroid Build Coastguard Worker 18*9880d681SAndroid Build Coastguard Worker; CHECK: entry.split: 19*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: br i1 %b, label %for.body, label %abort1.split 20*9880d681SAndroid Build Coastguard Worker 21*9880d681SAndroid Build Coastguard Worker; CHECK: for.body: 22*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: br label %for.body 23*9880d681SAndroid Build Coastguard Worker 24*9880d681SAndroid Build Coastguard Worker; CHECK: abort0.split: 25*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: call void @end0() [[NOR_NUW:#[0-9]+]] 26*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: unreachable 27*9880d681SAndroid Build Coastguard Worker 28*9880d681SAndroid Build Coastguard Worker; CHECK: abort1.split: 29*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: call void @end1() [[NOR_NUW]] 30*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: unreachable 31*9880d681SAndroid Build Coastguard Worker 32*9880d681SAndroid Build Coastguard Worker; CHECK: } 33*9880d681SAndroid Build Coastguard Worker 34*9880d681SAndroid Build Coastguard Workerdefine void @func_16(i1 %a, i1 %b) nounwind { 35*9880d681SAndroid Build Coastguard Workerentry: 36*9880d681SAndroid Build Coastguard Worker br label %for.body 37*9880d681SAndroid Build Coastguard Worker 38*9880d681SAndroid Build Coastguard Workerfor.body: 39*9880d681SAndroid Build Coastguard Worker br i1 %a, label %cond.end, label %abort0 40*9880d681SAndroid Build Coastguard Worker 41*9880d681SAndroid Build Coastguard Workercond.end: 42*9880d681SAndroid Build Coastguard Worker br i1 %b, label %for.body, label %abort1 43*9880d681SAndroid Build Coastguard Worker 44*9880d681SAndroid Build Coastguard Workerabort0: 45*9880d681SAndroid Build Coastguard Worker call void @end0() noreturn nounwind 46*9880d681SAndroid Build Coastguard Worker unreachable 47*9880d681SAndroid Build Coastguard Worker 48*9880d681SAndroid Build Coastguard Workerabort1: 49*9880d681SAndroid Build Coastguard Worker call void @end1() noreturn nounwind 50*9880d681SAndroid Build Coastguard Worker unreachable 51*9880d681SAndroid Build Coastguard Worker} 52*9880d681SAndroid Build Coastguard Worker 53*9880d681SAndroid Build Coastguard Workerdeclare void @end0() noreturn 54*9880d681SAndroid Build Coastguard Workerdeclare void @end1() noreturn 55*9880d681SAndroid Build Coastguard Worker 56*9880d681SAndroid Build Coastguard Worker; CHECK: attributes #0 = { nounwind } 57*9880d681SAndroid Build Coastguard Worker; CHECK: attributes #1 = { noreturn } 58*9880d681SAndroid Build Coastguard Worker; CHECK: attributes [[NOR_NUW]] = { noreturn nounwind } 59