Jingyue Wu | 42f1d67 | 2015-07-28 18:22:40 +0000 | [diff] [blame^] | 1 | ; RUN: opt -loop-reduce -S < %s | FileCheck %s |
| 2 | |
| 3 | target datalayout = "e-i64:64-v16:16-v32:32-n16:32:64" |
| 4 | target triple = "nvptx64-unknown-unknown" |
| 5 | |
| 6 | ; LSR used not to be able to generate a float* induction variable in |
| 7 | ; these cases due to scalar evolution not propagating nsw from an |
| 8 | ; instruction to the SCEV, preventing distributing sext into the |
| 9 | ; corresponding addrec. |
| 10 | |
| 11 | define float @testadd(float* %input, i32 %offset, i32 %numIterations) { |
| 12 | ; CHECK-LABEL: @testadd |
| 13 | ; CHECK: sext i32 %offset to i64 |
| 14 | ; CHECK: loop: |
| 15 | ; CHECK-DAG: phi float* |
| 16 | ; CHECK-DAG: phi i32 |
| 17 | ; CHECK-NOT: sext |
| 18 | |
| 19 | entry: |
| 20 | br label %loop |
| 21 | |
| 22 | loop: |
| 23 | %i = phi i32 [ %nexti, %loop ], [ 0, %entry ] |
| 24 | %sum = phi float [ %nextsum, %loop ], [ 0.000000e+00, %entry ] |
| 25 | %index32 = add nuw nsw i32 %i, %offset |
| 26 | %index64 = sext i32 %index32 to i64 |
| 27 | %ptr = getelementptr inbounds float, float* %input, i64 %index64 |
| 28 | %addend = load float, float* %ptr, align 4 |
| 29 | %nextsum = fadd float %sum, %addend |
| 30 | %nexti = add nuw nsw i32 %i, 1 |
| 31 | %exitcond = icmp eq i32 %nexti, %numIterations |
| 32 | br i1 %exitcond, label %exit, label %loop |
| 33 | |
| 34 | exit: |
| 35 | ret float %nextsum |
| 36 | } |