Wei Mi | 493fb26 | 2017-02-16 21:27:31 +0000 | [diff] [blame] | 1 | ; RUN: opt -loop-reduce -S < %s | FileCheck %s |
| 2 | ; We find it is very bad to allow LSR formula containing SCEVAddRecExpr Reg |
| 3 | ; from siblings of current loop. When one loop is LSR optimized, it can |
| 4 | ; insert lsr.iv for other sibling loops, which sometimes leads to many extra |
| 5 | ; lsr.iv inserted for loops. |
| 6 | |
| 7 | target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" |
| 8 | |
| 9 | @cond = common local_unnamed_addr global i64 0, align 8 |
| 10 | |
| 11 | ; Check there is no extra lsr.iv generated in foo. |
| 12 | ; CHECK-LABEL: @foo( |
| 13 | ; CHECK-NOT: lsr.iv{{[0-9]+}} = |
| 14 | ; |
| 15 | define void @foo(i64 %N) local_unnamed_addr { |
| 16 | entry: |
| 17 | br label %do.body |
| 18 | |
| 19 | do.body: ; preds = %do.body, %entry |
| 20 | %i.0 = phi i64 [ 0, %entry ], [ %inc, %do.body ] |
| 21 | tail call void @goo(i64 %i.0, i64 %i.0) |
| 22 | %inc = add nuw nsw i64 %i.0, 1 |
| 23 | %t0 = load i64, i64* @cond, align 8 |
| 24 | %tobool = icmp eq i64 %t0, 0 |
| 25 | br i1 %tobool, label %do.body2.preheader, label %do.body |
| 26 | |
| 27 | do.body2.preheader: ; preds = %do.body |
| 28 | br label %do.body2 |
| 29 | |
| 30 | do.body2: ; preds = %do.body2.preheader, %do.body2 |
| 31 | %i.1 = phi i64 [ %inc3, %do.body2 ], [ 0, %do.body2.preheader ] |
| 32 | %j.1 = phi i64 [ %inc4, %do.body2 ], [ %inc, %do.body2.preheader ] |
| 33 | tail call void @goo(i64 %i.1, i64 %j.1) |
| 34 | %inc3 = add nuw nsw i64 %i.1, 1 |
| 35 | %inc4 = add nsw i64 %j.1, 1 |
| 36 | %t1 = load i64, i64* @cond, align 8 |
| 37 | %tobool6 = icmp eq i64 %t1, 0 |
| 38 | br i1 %tobool6, label %do.body8.preheader, label %do.body2 |
| 39 | |
| 40 | do.body8.preheader: ; preds = %do.body2 |
| 41 | br label %do.body8 |
| 42 | |
| 43 | do.body8: ; preds = %do.body8.preheader, %do.body8 |
| 44 | %i.2 = phi i64 [ %inc9, %do.body8 ], [ 0, %do.body8.preheader ] |
| 45 | %j.2 = phi i64 [ %inc10, %do.body8 ], [ %inc4, %do.body8.preheader ] |
| 46 | tail call void @goo(i64 %i.2, i64 %j.2) |
| 47 | %inc9 = add nuw nsw i64 %i.2, 1 |
| 48 | %inc10 = add nsw i64 %j.2, 1 |
| 49 | %t2 = load i64, i64* @cond, align 8 |
| 50 | %tobool12 = icmp eq i64 %t2, 0 |
| 51 | br i1 %tobool12, label %do.body14.preheader, label %do.body8 |
| 52 | |
| 53 | do.body14.preheader: ; preds = %do.body8 |
| 54 | br label %do.body14 |
| 55 | |
| 56 | do.body14: ; preds = %do.body14.preheader, %do.body14 |
| 57 | %i.3 = phi i64 [ %inc15, %do.body14 ], [ 0, %do.body14.preheader ] |
| 58 | %j.3 = phi i64 [ %inc16, %do.body14 ], [ %inc10, %do.body14.preheader ] |
| 59 | tail call void @goo(i64 %i.3, i64 %j.3) |
| 60 | %inc15 = add nuw nsw i64 %i.3, 1 |
| 61 | %inc16 = add nsw i64 %j.3, 1 |
| 62 | %t3 = load i64, i64* @cond, align 8 |
| 63 | %tobool18 = icmp eq i64 %t3, 0 |
| 64 | br i1 %tobool18, label %do.body20.preheader, label %do.body14 |
| 65 | |
| 66 | do.body20.preheader: ; preds = %do.body14 |
| 67 | br label %do.body20 |
| 68 | |
| 69 | do.body20: ; preds = %do.body20.preheader, %do.body20 |
| 70 | %i.4 = phi i64 [ %inc21, %do.body20 ], [ 0, %do.body20.preheader ] |
| 71 | %j.4 = phi i64 [ %inc22, %do.body20 ], [ %inc16, %do.body20.preheader ] |
| 72 | tail call void @goo(i64 %i.4, i64 %j.4) |
| 73 | %inc21 = add nuw nsw i64 %i.4, 1 |
| 74 | %inc22 = add nsw i64 %j.4, 1 |
| 75 | %t4 = load i64, i64* @cond, align 8 |
| 76 | %tobool24 = icmp eq i64 %t4, 0 |
| 77 | br i1 %tobool24, label %do.body26.preheader, label %do.body20 |
| 78 | |
| 79 | do.body26.preheader: ; preds = %do.body20 |
| 80 | br label %do.body26 |
| 81 | |
| 82 | do.body26: ; preds = %do.body26.preheader, %do.body26 |
| 83 | %i.5 = phi i64 [ %inc27, %do.body26 ], [ 0, %do.body26.preheader ] |
| 84 | %j.5 = phi i64 [ %inc28, %do.body26 ], [ %inc22, %do.body26.preheader ] |
| 85 | tail call void @goo(i64 %i.5, i64 %j.5) |
| 86 | %inc27 = add nuw nsw i64 %i.5, 1 |
| 87 | %inc28 = add nsw i64 %j.5, 1 |
| 88 | %t5 = load i64, i64* @cond, align 8 |
| 89 | %tobool30 = icmp eq i64 %t5, 0 |
| 90 | br i1 %tobool30, label %do.end31, label %do.body26 |
| 91 | |
| 92 | do.end31: ; preds = %do.body26 |
| 93 | ret void |
| 94 | } |
| 95 | |
| 96 | declare void @goo(i64, i64) local_unnamed_addr |
| 97 | |