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