Sanjoy Das | a1837a3 | 2015-01-16 01:03:22 +0000 | [diff] [blame] | 1 | ; RUN: opt -irce-print-changed-loops -irce -S < %s 2>&1 | FileCheck %s |
| 2 | |
| 3 | ; Demonstrates that we don't currently handle the general expression |
| 4 | ; `A * I + B'. |
| 5 | |
| 6 | define void @general_affine_expressions(i32 *%arr, i32 *%a_len_ptr, i32 %n, |
| 7 | i32 %scale, i32 %offset) { |
| 8 | ; CHECK-NOT: constrained Loop at depth |
| 9 | entry: |
| 10 | %len = load i32* %a_len_ptr, !range !0 |
| 11 | %first.itr.check = icmp sgt i32 %n, 0 |
| 12 | br i1 %first.itr.check, label %loop, label %exit |
| 13 | |
| 14 | loop: |
| 15 | %idx = phi i32 [ 0, %entry ] , [ %idx.next, %in.bounds ] |
| 16 | %idx.next = add i32 %idx, 1 |
| 17 | %idx.mul = mul i32 %idx, %scale |
| 18 | %array.idx = add i32 %idx.mul, %offset |
| 19 | %abc.high = icmp slt i32 %array.idx, %len |
| 20 | %abc.low = icmp sge i32 %array.idx, 0 |
| 21 | %abc = and i1 %abc.low, %abc.high |
| 22 | br i1 %abc, label %in.bounds, label %out.of.bounds |
| 23 | |
| 24 | in.bounds: |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame^] | 25 | %addr = getelementptr i32, i32* %arr, i32 %array.idx |
Sanjoy Das | a1837a3 | 2015-01-16 01:03:22 +0000 | [diff] [blame] | 26 | store i32 0, i32* %addr |
| 27 | %next = icmp slt i32 %idx.next, %n |
| 28 | br i1 %next, label %loop, label %exit |
| 29 | |
| 30 | out.of.bounds: |
| 31 | ret void |
| 32 | |
| 33 | exit: |
| 34 | ret void |
| 35 | } |
| 36 | |
| 37 | !0 = !{i32 0, i32 2147483647} |