This reverts commit 62d1a080e69e3c5e98840e000135afa7c688a77b. This appears to be causing some runtime failures on RISCV https://lab.llvm.org/buildbot/#/builders/210/builds/5221
245 lines
12 KiB
LLVM
245 lines
12 KiB
LLVM
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-globals none --version 6
|
|
; RUN: opt -passes=loop-vectorize -force-vector-width=2 -force-vector-interleave=1 -prefer-predicate-over-epilogue=predicate-dont-vectorize -S %s | FileCheck --check-prefix=VF2IC1 %s
|
|
; RUN: opt -passes=loop-vectorize -force-vector-width=2 -force-vector-interleave=2 -prefer-predicate-over-epilogue=predicate-dont-vectorize -S %s | FileCheck --check-prefix=VF2IC2 %s
|
|
; RUN: opt -passes=loop-vectorize -force-vector-width=1 -force-vector-interleave=2 -prefer-predicate-over-epilogue=predicate-dont-vectorize -S %s | FileCheck --check-prefix=VF1IC2 %s
|
|
|
|
define i32 @FOR_used_outside(ptr noalias %A, ptr noalias %B, i64 %n) {
|
|
; VF2IC1-LABEL: define i32 @FOR_used_outside(
|
|
; VF2IC1-SAME: ptr noalias [[A:%.*]], ptr noalias [[B:%.*]], i64 [[N:%.*]]) {
|
|
; VF2IC1-NEXT: [[ENTRY:.*]]:
|
|
; VF2IC1-NEXT: br label %[[LOOP:.*]]
|
|
; VF2IC1: [[LOOP]]:
|
|
; VF2IC1-NEXT: [[TMP1:%.*]] = phi i64 [ 0, %[[ENTRY]] ], [ [[IV_NEXT:%.*]], %[[LOOP]] ]
|
|
; VF2IC1-NEXT: [[FOR:%.*]] = phi i32 [ 33, %[[ENTRY]] ], [ [[TMP10:%.*]], %[[LOOP]] ]
|
|
; VF2IC1-NEXT: [[TMP9:%.*]] = getelementptr inbounds nuw i32, ptr [[A]], i64 [[TMP1]]
|
|
; VF2IC1-NEXT: [[TMP10]] = load i32, ptr [[TMP9]], align 4
|
|
; VF2IC1-NEXT: [[TMP23:%.*]] = add nsw i32 [[FOR]], [[TMP10]]
|
|
; VF2IC1-NEXT: [[TMP20:%.*]] = getelementptr inbounds nuw i32, ptr [[B]], i64 [[TMP1]]
|
|
; VF2IC1-NEXT: store i32 [[TMP23]], ptr [[TMP20]], align 4
|
|
; VF2IC1-NEXT: [[IV_NEXT]] = add nuw nsw i64 [[TMP1]], 1
|
|
; VF2IC1-NEXT: [[EC:%.*]] = icmp eq i64 [[IV_NEXT]], [[N]]
|
|
; VF2IC1-NEXT: br i1 [[EC]], label %[[FOR_END:.*]], label %[[LOOP]]
|
|
; VF2IC1: [[FOR_END]]:
|
|
; VF2IC1-NEXT: [[TMP32:%.*]] = phi i32 [ [[FOR]], %[[LOOP]] ]
|
|
; VF2IC1-NEXT: ret i32 [[TMP32]]
|
|
;
|
|
; VF2IC2-LABEL: define i32 @FOR_used_outside(
|
|
; VF2IC2-SAME: ptr noalias [[A:%.*]], ptr noalias [[B:%.*]], i64 [[N:%.*]]) {
|
|
; VF2IC2-NEXT: [[ENTRY:.*]]:
|
|
; VF2IC2-NEXT: br label %[[LOOP:.*]]
|
|
; VF2IC2: [[LOOP]]:
|
|
; VF2IC2-NEXT: [[TMP3:%.*]] = phi i64 [ 0, %[[ENTRY]] ], [ [[IV_NEXT:%.*]], %[[LOOP]] ]
|
|
; VF2IC2-NEXT: [[FOR:%.*]] = phi i32 [ 33, %[[ENTRY]] ], [ [[TMP23:%.*]], %[[LOOP]] ]
|
|
; VF2IC2-NEXT: [[TMP22:%.*]] = getelementptr inbounds nuw i32, ptr [[A]], i64 [[TMP3]]
|
|
; VF2IC2-NEXT: [[TMP23]] = load i32, ptr [[TMP22]], align 4
|
|
; VF2IC2-NEXT: [[TMP47:%.*]] = add nsw i32 [[FOR]], [[TMP23]]
|
|
; VF2IC2-NEXT: [[TMP44:%.*]] = getelementptr inbounds nuw i32, ptr [[B]], i64 [[TMP3]]
|
|
; VF2IC2-NEXT: store i32 [[TMP47]], ptr [[TMP44]], align 4
|
|
; VF2IC2-NEXT: [[IV_NEXT]] = add nuw nsw i64 [[TMP3]], 1
|
|
; VF2IC2-NEXT: [[EC:%.*]] = icmp eq i64 [[IV_NEXT]], [[N]]
|
|
; VF2IC2-NEXT: br i1 [[EC]], label %[[FOR_END:.*]], label %[[LOOP]]
|
|
; VF2IC2: [[FOR_END]]:
|
|
; VF2IC2-NEXT: [[TMP66:%.*]] = phi i32 [ [[FOR]], %[[LOOP]] ]
|
|
; VF2IC2-NEXT: ret i32 [[TMP66]]
|
|
;
|
|
; VF1IC2-LABEL: define i32 @FOR_used_outside(
|
|
; VF1IC2-SAME: ptr noalias [[A:%.*]], ptr noalias [[B:%.*]], i64 [[N:%.*]]) {
|
|
; VF1IC2-NEXT: [[ENTRY:.*]]:
|
|
; VF1IC2-NEXT: br label %[[LOOP:.*]]
|
|
; VF1IC2: [[LOOP]]:
|
|
; VF1IC2-NEXT: [[TMP0:%.*]] = phi i64 [ 0, %[[ENTRY]] ], [ [[IV_NEXT:%.*]], %[[LOOP]] ]
|
|
; VF1IC2-NEXT: [[FOR:%.*]] = phi i32 [ 33, %[[ENTRY]] ], [ [[TMP7:%.*]], %[[LOOP]] ]
|
|
; VF1IC2-NEXT: [[TMP6:%.*]] = getelementptr inbounds nuw i32, ptr [[A]], i64 [[TMP0]]
|
|
; VF1IC2-NEXT: [[TMP7]] = load i32, ptr [[TMP6]], align 4
|
|
; VF1IC2-NEXT: [[TMP12:%.*]] = add nsw i32 [[FOR]], [[TMP7]]
|
|
; VF1IC2-NEXT: [[TMP11:%.*]] = getelementptr inbounds nuw i32, ptr [[B]], i64 [[TMP0]]
|
|
; VF1IC2-NEXT: store i32 [[TMP12]], ptr [[TMP11]], align 4
|
|
; VF1IC2-NEXT: [[IV_NEXT]] = add nuw nsw i64 [[TMP0]], 1
|
|
; VF1IC2-NEXT: [[EC:%.*]] = icmp eq i64 [[IV_NEXT]], [[N]]
|
|
; VF1IC2-NEXT: br i1 [[EC]], label %[[FOR_END:.*]], label %[[LOOP]]
|
|
; VF1IC2: [[FOR_END]]:
|
|
; VF1IC2-NEXT: [[TMP30:%.*]] = phi i32 [ [[FOR]], %[[LOOP]] ]
|
|
; VF1IC2-NEXT: ret i32 [[TMP30]]
|
|
;
|
|
entry:
|
|
br label %loop
|
|
|
|
loop:
|
|
%iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
|
|
%for = phi i32 [ 33, %entry ], [ %for.next, %loop ]
|
|
%gep.A = getelementptr inbounds nuw i32, ptr %A, i64 %iv
|
|
%for.next = load i32, ptr %gep.A, align 4
|
|
%add = add nsw i32 %for, %for.next
|
|
%gep.B = getelementptr inbounds nuw i32, ptr %B, i64 %iv
|
|
store i32 %add, ptr %gep.B, align 4
|
|
%iv.next = add nuw nsw i64 %iv, 1
|
|
%ec = icmp eq i64 %iv.next, %n
|
|
br i1 %ec, label %for.end, label %loop
|
|
|
|
for.end:
|
|
ret i32 %for
|
|
}
|
|
|
|
define i32 @FOR_next_used_outside(ptr noalias %A, ptr noalias %B, i64 %n) {
|
|
; VF2IC1-LABEL: define i32 @FOR_next_used_outside(
|
|
; VF2IC1-SAME: ptr noalias [[A:%.*]], ptr noalias [[B:%.*]], i64 [[N:%.*]]) {
|
|
; VF2IC1-NEXT: [[ENTRY:.*]]:
|
|
; VF2IC1-NEXT: br label %[[LOOP:.*]]
|
|
; VF2IC1: [[LOOP]]:
|
|
; VF2IC1-NEXT: [[TMP1:%.*]] = phi i64 [ 0, %[[ENTRY]] ], [ [[IV_NEXT:%.*]], %[[LOOP]] ]
|
|
; VF2IC1-NEXT: [[FOR:%.*]] = phi i32 [ 33, %[[ENTRY]] ], [ [[TMP10:%.*]], %[[LOOP]] ]
|
|
; VF2IC1-NEXT: [[TMP9:%.*]] = getelementptr inbounds nuw i32, ptr [[A]], i64 [[TMP1]]
|
|
; VF2IC1-NEXT: [[TMP10]] = load i32, ptr [[TMP9]], align 4
|
|
; VF2IC1-NEXT: [[TMP23:%.*]] = add nsw i32 [[FOR]], [[TMP10]]
|
|
; VF2IC1-NEXT: [[TMP20:%.*]] = getelementptr inbounds nuw i32, ptr [[B]], i64 [[TMP1]]
|
|
; VF2IC1-NEXT: store i32 [[TMP23]], ptr [[TMP20]], align 4
|
|
; VF2IC1-NEXT: [[IV_NEXT]] = add nuw nsw i64 [[TMP1]], 1
|
|
; VF2IC1-NEXT: [[EC:%.*]] = icmp eq i64 [[IV_NEXT]], [[N]]
|
|
; VF2IC1-NEXT: br i1 [[EC]], label %[[FOR_END:.*]], label %[[LOOP]]
|
|
; VF2IC1: [[FOR_END]]:
|
|
; VF2IC1-NEXT: [[TMP28:%.*]] = phi i32 [ [[TMP10]], %[[LOOP]] ]
|
|
; VF2IC1-NEXT: ret i32 [[TMP28]]
|
|
;
|
|
; VF2IC2-LABEL: define i32 @FOR_next_used_outside(
|
|
; VF2IC2-SAME: ptr noalias [[A:%.*]], ptr noalias [[B:%.*]], i64 [[N:%.*]]) {
|
|
; VF2IC2-NEXT: [[ENTRY:.*]]:
|
|
; VF2IC2-NEXT: br label %[[LOOP:.*]]
|
|
; VF2IC2: [[LOOP]]:
|
|
; VF2IC2-NEXT: [[TMP3:%.*]] = phi i64 [ 0, %[[ENTRY]] ], [ [[IV_NEXT:%.*]], %[[LOOP]] ]
|
|
; VF2IC2-NEXT: [[FOR:%.*]] = phi i32 [ 33, %[[ENTRY]] ], [ [[TMP23:%.*]], %[[LOOP]] ]
|
|
; VF2IC2-NEXT: [[TMP22:%.*]] = getelementptr inbounds nuw i32, ptr [[A]], i64 [[TMP3]]
|
|
; VF2IC2-NEXT: [[TMP23]] = load i32, ptr [[TMP22]], align 4
|
|
; VF2IC2-NEXT: [[TMP47:%.*]] = add nsw i32 [[FOR]], [[TMP23]]
|
|
; VF2IC2-NEXT: [[TMP44:%.*]] = getelementptr inbounds nuw i32, ptr [[B]], i64 [[TMP3]]
|
|
; VF2IC2-NEXT: store i32 [[TMP47]], ptr [[TMP44]], align 4
|
|
; VF2IC2-NEXT: [[IV_NEXT]] = add nuw nsw i64 [[TMP3]], 1
|
|
; VF2IC2-NEXT: [[EC:%.*]] = icmp eq i64 [[IV_NEXT]], [[N]]
|
|
; VF2IC2-NEXT: br i1 [[EC]], label %[[FOR_END:.*]], label %[[LOOP]]
|
|
; VF2IC2: [[FOR_END]]:
|
|
; VF2IC2-NEXT: [[TMP62:%.*]] = phi i32 [ [[TMP23]], %[[LOOP]] ]
|
|
; VF2IC2-NEXT: ret i32 [[TMP62]]
|
|
;
|
|
; VF1IC2-LABEL: define i32 @FOR_next_used_outside(
|
|
; VF1IC2-SAME: ptr noalias [[A:%.*]], ptr noalias [[B:%.*]], i64 [[N:%.*]]) {
|
|
; VF1IC2-NEXT: [[ENTRY:.*]]:
|
|
; VF1IC2-NEXT: br label %[[LOOP:.*]]
|
|
; VF1IC2: [[LOOP]]:
|
|
; VF1IC2-NEXT: [[TMP0:%.*]] = phi i64 [ 0, %[[ENTRY]] ], [ [[IV_NEXT:%.*]], %[[LOOP]] ]
|
|
; VF1IC2-NEXT: [[FOR:%.*]] = phi i32 [ 33, %[[ENTRY]] ], [ [[TMP7:%.*]], %[[LOOP]] ]
|
|
; VF1IC2-NEXT: [[TMP6:%.*]] = getelementptr inbounds nuw i32, ptr [[A]], i64 [[TMP0]]
|
|
; VF1IC2-NEXT: [[TMP7]] = load i32, ptr [[TMP6]], align 4
|
|
; VF1IC2-NEXT: [[TMP12:%.*]] = add nsw i32 [[FOR]], [[TMP7]]
|
|
; VF1IC2-NEXT: [[TMP11:%.*]] = getelementptr inbounds nuw i32, ptr [[B]], i64 [[TMP0]]
|
|
; VF1IC2-NEXT: store i32 [[TMP12]], ptr [[TMP11]], align 4
|
|
; VF1IC2-NEXT: [[IV_NEXT]] = add nuw nsw i64 [[TMP0]], 1
|
|
; VF1IC2-NEXT: [[EC:%.*]] = icmp eq i64 [[IV_NEXT]], [[N]]
|
|
; VF1IC2-NEXT: br i1 [[EC]], label %[[FOR_END:.*]], label %[[LOOP]]
|
|
; VF1IC2: [[FOR_END]]:
|
|
; VF1IC2-NEXT: [[TMP27:%.*]] = phi i32 [ [[TMP7]], %[[LOOP]] ]
|
|
; VF1IC2-NEXT: ret i32 [[TMP27]]
|
|
;
|
|
entry:
|
|
br label %loop
|
|
|
|
loop:
|
|
%iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
|
|
%for = phi i32 [ 33, %entry ], [ %for.next, %loop ]
|
|
%gep.A = getelementptr inbounds nuw i32, ptr %A, i64 %iv
|
|
%for.next = load i32, ptr %gep.A, align 4
|
|
%add = add nsw i32 %for, %for.next
|
|
%gep.B = getelementptr inbounds nuw i32, ptr %B, i64 %iv
|
|
store i32 %add, ptr %gep.B, align 4
|
|
%iv.next = add nuw nsw i64 %iv, 1
|
|
%ec = icmp eq i64 %iv.next, %n
|
|
br i1 %ec, label %for.end, label %loop
|
|
|
|
for.end:
|
|
ret i32 %for.next
|
|
}
|
|
|
|
define i32 @FOR_and_next_used_outside(ptr noalias %A, ptr noalias %B, i64 %n) {
|
|
; VF2IC1-LABEL: define i32 @FOR_and_next_used_outside(
|
|
; VF2IC1-SAME: ptr noalias [[A:%.*]], ptr noalias [[B:%.*]], i64 [[N:%.*]]) {
|
|
; VF2IC1-NEXT: [[ENTRY:.*]]:
|
|
; VF2IC1-NEXT: br label %[[LOOP:.*]]
|
|
; VF2IC1: [[LOOP]]:
|
|
; VF2IC1-NEXT: [[TMP1:%.*]] = phi i64 [ 0, %[[ENTRY]] ], [ [[IV_NEXT:%.*]], %[[LOOP]] ]
|
|
; VF2IC1-NEXT: [[FOR:%.*]] = phi i32 [ 33, %[[ENTRY]] ], [ [[TMP10:%.*]], %[[LOOP]] ]
|
|
; VF2IC1-NEXT: [[TMP9:%.*]] = getelementptr inbounds nuw i32, ptr [[A]], i64 [[TMP1]]
|
|
; VF2IC1-NEXT: [[TMP10]] = load i32, ptr [[TMP9]], align 4
|
|
; VF2IC1-NEXT: [[TMP23:%.*]] = add nsw i32 [[FOR]], [[TMP10]]
|
|
; VF2IC1-NEXT: [[TMP20:%.*]] = getelementptr inbounds nuw i32, ptr [[B]], i64 [[TMP1]]
|
|
; VF2IC1-NEXT: store i32 [[TMP23]], ptr [[TMP20]], align 4
|
|
; VF2IC1-NEXT: [[IV_NEXT]] = add nuw nsw i64 [[TMP1]], 1
|
|
; VF2IC1-NEXT: [[EC:%.*]] = icmp eq i64 [[IV_NEXT]], [[N]]
|
|
; VF2IC1-NEXT: br i1 [[EC]], label %[[FOR_END:.*]], label %[[LOOP]]
|
|
; VF2IC1: [[FOR_END]]:
|
|
; VF2IC1-NEXT: [[TMP32:%.*]] = phi i32 [ [[FOR]], %[[LOOP]] ]
|
|
; VF2IC1-NEXT: [[TMP33:%.*]] = phi i32 [ [[TMP10]], %[[LOOP]] ]
|
|
; VF2IC1-NEXT: [[RES:%.*]] = add i32 [[TMP32]], [[TMP33]]
|
|
; VF2IC1-NEXT: ret i32 [[RES]]
|
|
;
|
|
; VF2IC2-LABEL: define i32 @FOR_and_next_used_outside(
|
|
; VF2IC2-SAME: ptr noalias [[A:%.*]], ptr noalias [[B:%.*]], i64 [[N:%.*]]) {
|
|
; VF2IC2-NEXT: [[ENTRY:.*]]:
|
|
; VF2IC2-NEXT: br label %[[LOOP:.*]]
|
|
; VF2IC2: [[LOOP]]:
|
|
; VF2IC2-NEXT: [[TMP3:%.*]] = phi i64 [ 0, %[[ENTRY]] ], [ [[IV_NEXT:%.*]], %[[LOOP]] ]
|
|
; VF2IC2-NEXT: [[FOR:%.*]] = phi i32 [ 33, %[[ENTRY]] ], [ [[TMP23:%.*]], %[[LOOP]] ]
|
|
; VF2IC2-NEXT: [[TMP22:%.*]] = getelementptr inbounds nuw i32, ptr [[A]], i64 [[TMP3]]
|
|
; VF2IC2-NEXT: [[TMP23]] = load i32, ptr [[TMP22]], align 4
|
|
; VF2IC2-NEXT: [[TMP47:%.*]] = add nsw i32 [[FOR]], [[TMP23]]
|
|
; VF2IC2-NEXT: [[TMP44:%.*]] = getelementptr inbounds nuw i32, ptr [[B]], i64 [[TMP3]]
|
|
; VF2IC2-NEXT: store i32 [[TMP47]], ptr [[TMP44]], align 4
|
|
; VF2IC2-NEXT: [[IV_NEXT]] = add nuw nsw i64 [[TMP3]], 1
|
|
; VF2IC2-NEXT: [[EC:%.*]] = icmp eq i64 [[IV_NEXT]], [[N]]
|
|
; VF2IC2-NEXT: br i1 [[EC]], label %[[FOR_END:.*]], label %[[LOOP]]
|
|
; VF2IC2: [[FOR_END]]:
|
|
; VF2IC2-NEXT: [[TMP66:%.*]] = phi i32 [ [[FOR]], %[[LOOP]] ]
|
|
; VF2IC2-NEXT: [[TMP71:%.*]] = phi i32 [ [[TMP23]], %[[LOOP]] ]
|
|
; VF2IC2-NEXT: [[RES:%.*]] = add i32 [[TMP66]], [[TMP71]]
|
|
; VF2IC2-NEXT: ret i32 [[RES]]
|
|
;
|
|
; VF1IC2-LABEL: define i32 @FOR_and_next_used_outside(
|
|
; VF1IC2-SAME: ptr noalias [[A:%.*]], ptr noalias [[B:%.*]], i64 [[N:%.*]]) {
|
|
; VF1IC2-NEXT: [[ENTRY:.*]]:
|
|
; VF1IC2-NEXT: br label %[[LOOP:.*]]
|
|
; VF1IC2: [[LOOP]]:
|
|
; VF1IC2-NEXT: [[TMP0:%.*]] = phi i64 [ 0, %[[ENTRY]] ], [ [[IV_NEXT:%.*]], %[[LOOP]] ]
|
|
; VF1IC2-NEXT: [[FOR:%.*]] = phi i32 [ 33, %[[ENTRY]] ], [ [[TMP7:%.*]], %[[LOOP]] ]
|
|
; VF1IC2-NEXT: [[TMP6:%.*]] = getelementptr inbounds nuw i32, ptr [[A]], i64 [[TMP0]]
|
|
; VF1IC2-NEXT: [[TMP7]] = load i32, ptr [[TMP6]], align 4
|
|
; VF1IC2-NEXT: [[TMP12:%.*]] = add nsw i32 [[FOR]], [[TMP7]]
|
|
; VF1IC2-NEXT: [[TMP11:%.*]] = getelementptr inbounds nuw i32, ptr [[B]], i64 [[TMP0]]
|
|
; VF1IC2-NEXT: store i32 [[TMP12]], ptr [[TMP11]], align 4
|
|
; VF1IC2-NEXT: [[IV_NEXT]] = add nuw nsw i64 [[TMP0]], 1
|
|
; VF1IC2-NEXT: [[EC:%.*]] = icmp eq i64 [[IV_NEXT]], [[N]]
|
|
; VF1IC2-NEXT: br i1 [[EC]], label %[[FOR_END:.*]], label %[[LOOP]]
|
|
; VF1IC2: [[FOR_END]]:
|
|
; VF1IC2-NEXT: [[TMP30:%.*]] = phi i32 [ [[FOR]], %[[LOOP]] ]
|
|
; VF1IC2-NEXT: [[TMP33:%.*]] = phi i32 [ [[TMP7]], %[[LOOP]] ]
|
|
; VF1IC2-NEXT: [[RES:%.*]] = add i32 [[TMP30]], [[TMP33]]
|
|
; VF1IC2-NEXT: ret i32 [[RES]]
|
|
;
|
|
entry:
|
|
br label %loop
|
|
|
|
loop:
|
|
%iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
|
|
%for = phi i32 [ 33, %entry ], [ %for.next, %loop ]
|
|
%gep.A = getelementptr inbounds nuw i32, ptr %A, i64 %iv
|
|
%for.next = load i32, ptr %gep.A, align 4
|
|
%add = add nsw i32 %for, %for.next
|
|
%gep.B = getelementptr inbounds nuw i32, ptr %B, i64 %iv
|
|
store i32 %add, ptr %gep.B, align 4
|
|
%iv.next = add nuw nsw i64 %iv, 1
|
|
%ec = icmp eq i64 %iv.next, %n
|
|
br i1 %ec, label %for.end, label %loop
|
|
|
|
for.end:
|
|
%res = add i32 %for, %for.next
|
|
ret i32 %res
|
|
}
|
|
|
|
|