Serguei Katkov | 529f423 | 2018-03-19 06:35:30 +0000 | [diff] [blame] | 1 | ; RUN: opt < %s -analyze -iv-users -S | FileCheck %s |
| 2 | |
| 3 | ; This is a regression test for the commit rL327362. |
| 4 | |
| 5 | target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128-ni:1" |
| 6 | target triple = "x86_64-unknown-linux-gnu" |
| 7 | |
| 8 | define void @test(i64 %a, i64* %p) { |
| 9 | entry: |
| 10 | br label %first_loop |
| 11 | |
| 12 | first_loop: |
| 13 | %i = phi i64 [20, %entry], [%i.next, %first_loop] |
| 14 | %i.next = add nuw nsw i64 %i, 1 |
| 15 | %cond1 = icmp ult i64 %i.next, %a |
| 16 | br i1 %cond1, label %first_loop, label %middle_block |
| 17 | |
| 18 | middle_block: |
| 19 | %b = load i64, i64* %p |
| 20 | %cmp = icmp ult i64 %i, %b |
| 21 | ; When SCEV will try to compute the initial value for %j |
| 22 | ; it will observe umax generated by this select. |
| 23 | ; When it will try to simplify this umax it will invoke |
| 24 | ; isKnownPredicate with AddRec for %i and unknown SCEV for %b. |
| 25 | ; As a result we find MDL == first_loop where %b is not available |
| 26 | ; at loop entry. |
| 27 | ; CHECK: IV Users for loop %second_loop with backedge-taken count{{.*}}umax |
| 28 | %s = select i1 %cmp, i64 %i, i64 %b |
| 29 | br label %second_loop |
| 30 | |
| 31 | second_loop: |
| 32 | %j = phi i64 [%s, %middle_block], [%j.next, %second_loop] |
| 33 | %j.next = add nuw nsw i64 %j, 1 |
| 34 | %cond2 = icmp ult i64 %j.next, 100 |
| 35 | br i1 %cond2, label %second_loop, label %return |
| 36 | |
| 37 | return: |
| 38 | ret void |
| 39 | } |