|
| 1 | +; RUN: opt < %s -loop-vectorize -mtriple=riscv64 -mattr=+experimental-v -riscv-v-vector-bits-min=128 -S | FileCheck %s |
| 2 | +; RUN: opt < %s -loop-vectorize -mtriple=riscv32 -mattr=+experimental-v -riscv-v-vector-bits-min=128 -S | FileCheck %s |
| 3 | + |
| 4 | +; Function Attrs: nounwind |
| 5 | +define i32* @array_add(i32* noalias nocapture readonly %a, i32* noalias nocapture readonly %b, i32* %c, i32 %size) { |
| 6 | +;CHECK-LABEL: array_add |
| 7 | +;CHECK: load <4 x i32> |
| 8 | +;CHECK: load <4 x i32> |
| 9 | +;CHECK: add nsw <4 x i32> |
| 10 | +;CHECK: store <4 x i32> |
| 11 | +;CHECK: ret |
| 12 | +entry: |
| 13 | + %cmp10 = icmp sgt i32 %size, 0 |
| 14 | + br i1 %cmp10, label %for.body.preheader, label %for.end |
| 15 | + |
| 16 | +for.body.preheader: ; preds = %entry |
| 17 | + br label %for.body |
| 18 | + |
| 19 | +for.body: ; preds = %for.body.preheader, %for.body |
| 20 | + %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %for.body.preheader ] |
| 21 | + %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv |
| 22 | + %0 = load i32, i32* %arrayidx, align 4 |
| 23 | + %arrayidx2 = getelementptr inbounds i32, i32* %b, i64 %indvars.iv |
| 24 | + %1 = load i32, i32* %arrayidx2, align 4 |
| 25 | + %add = add nsw i32 %1, %0 |
| 26 | + %arrayidx4 = getelementptr inbounds i32, i32* %c, i64 %indvars.iv |
| 27 | + store i32 %add, i32* %arrayidx4, align 4 |
| 28 | + %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1 |
| 29 | + %lftr.wideiv = trunc i64 %indvars.iv.next to i32 |
| 30 | + %exitcond = icmp eq i32 %lftr.wideiv, %size |
| 31 | + br i1 %exitcond, label %for.end.loopexit, label %for.body |
| 32 | + |
| 33 | +for.end.loopexit: ; preds = %for.body |
| 34 | + br label %for.end |
| 35 | + |
| 36 | +for.end: ; preds = %for.end.loopexit, %entry |
| 37 | + ret i32* %c |
| 38 | +} |
0 commit comments