Serge Guelton | 7bc405a | 2017-06-27 18:57:53 +0000 | [diff] [blame^] | 1 | ; RUN: opt < %s -loop-extract -S | FileCheck %s |
| 2 | |
| 3 | @label = common local_unnamed_addr global i8* null |
| 4 | |
| 5 | ; CHECK: define |
| 6 | ; no outlined function |
| 7 | ; CHECK-NOT: define |
| 8 | define i32 @sterix(i32 %n) { |
| 9 | entry: |
| 10 | %tobool = icmp ne i32 %n, 0 |
| 11 | ; this blockaddress references a basic block that goes in the extracted loop |
| 12 | %cond = select i1 %tobool, i8* blockaddress(@sterix, %for.cond), i8* blockaddress(@sterix, %exit) |
| 13 | store i8* %cond, i8** @label |
| 14 | %cmp5 = icmp sgt i32 %n, 0 |
| 15 | br i1 %cmp5, label %for.body, label %exit |
| 16 | |
| 17 | for.cond: |
| 18 | %mul = shl nsw i32 %s.06, 1 |
| 19 | %exitcond = icmp eq i32 %inc, %n |
| 20 | br i1 %exitcond, label %exit.loopexit, label %for.body |
| 21 | |
| 22 | for.body: |
| 23 | %i.07 = phi i32 [ %inc, %for.cond ], [ 0, %entry ] |
| 24 | %s.06 = phi i32 [ %mul, %for.cond ], [ 1, %entry ] |
| 25 | %inc = add nuw nsw i32 %i.07, 1 |
| 26 | br label %for.cond |
| 27 | |
| 28 | exit.loopexit: |
| 29 | %phitmp = icmp ne i32 %s.06, 2 |
| 30 | %phitmp8 = zext i1 %phitmp to i32 |
| 31 | br label %exit |
| 32 | |
| 33 | exit: |
| 34 | %s.1 = phi i32 [ 1, %entry ], [ %phitmp8, %exit.loopexit ] |
| 35 | ret i32 %s.1 |
| 36 | } |