Eric Christopher | cee313d | 2019-04-17 04:52:47 +0000 | [diff] [blame] | 1 | ; RUN: opt < %s -indvars -S | FileCheck %s |
| 2 | |
| 3 | target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128-ni:1" |
| 4 | target triple = "x86_64-unknown-linux-gnu" |
| 5 | |
| 6 | declare void @foo(i64) |
| 7 | |
| 8 | ; CHECK-LABEL: @test |
| 9 | define void @test(i64 %a) { |
| 10 | entry: |
| 11 | br label %outer_header |
| 12 | |
| 13 | outer_header: |
| 14 | %i = phi i64 [20, %entry], [%i.next, %outer_latch] |
| 15 | %i.next = add nuw nsw i64 %i, 1 |
| 16 | br label %inner_header |
| 17 | |
| 18 | inner_header: |
| 19 | %j = phi i64 [1, %outer_header], [%j.next, %inner_header] |
| 20 | %cmp = icmp ult i64 %j, %i.next |
| 21 | ; CHECK-NOT: select |
| 22 | %s = select i1 %cmp, i64 %j, i64 %i |
| 23 | ; CHECK: call void @foo(i64 %j) |
| 24 | call void @foo(i64 %s) |
| 25 | %j.next = add nuw nsw i64 %j, 1 |
| 26 | %cond = icmp ult i64 %j, %i |
| 27 | br i1 %cond, label %inner_header, label %outer_latch |
| 28 | |
| 29 | outer_latch: |
| 30 | %cond2 = icmp ne i64 %i.next, 40 |
| 31 | br i1 %cond2, label %outer_header, label %return |
| 32 | |
| 33 | return: |
| 34 | ret void |
| 35 | } |