[llvm] 110ec18 - LoopVectorize/iv-select-cmp: add test for decreasing IV, const start

Ramkumar Ramachandra via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 26 06:15:39 PDT 2023


Author: Ramkumar Ramachandra
Date: 2023-07-26T14:15:26+01:00
New Revision: 110ec1863af6a54d0cb646ca93867aec9f1e8fdc

URL: https://github.com/llvm/llvm-project/commit/110ec1863af6a54d0cb646ca93867aec9f1e8fdc
DIFF: https://github.com/llvm/llvm-project/commit/110ec1863af6a54d0cb646ca93867aec9f1e8fdc.diff

LOG: LoopVectorize/iv-select-cmp: add test for decreasing IV, const start

The most straightforward extension to D150851 would involve a loop with
decreasing induction variable, with a constant start value.
iv-select-cmp.ll only contains a negative test for the decreasing
induction variable case when the start value is variable, namely
not_vectorized_select_decreasing_induction_icmp. Hence, add a test for
the most straightforward extension to D150851, in preparation to
vectorize:

  long rdx = 331;
  for (long i = 19999; i >= 0; i--) {
    if (a[i] > 3)
      rdx = i;
  }
  return rdx;

Differential Revision: https://reviews.llvm.org/D156152

Added: 
    

Modified: 
    llvm/test/Transforms/LoopVectorize/iv-select-cmp.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/LoopVectorize/iv-select-cmp.ll b/llvm/test/Transforms/LoopVectorize/iv-select-cmp.ll
index a67b4eb5cc631b..cd176a3c949225 100644
--- a/llvm/test/Transforms/LoopVectorize/iv-select-cmp.ll
+++ b/llvm/test/Transforms/LoopVectorize/iv-select-cmp.ll
@@ -214,8 +214,30 @@ exit:                                             ; preds = %for.body
   ret float %cond
 }
 
-define i64 @not_vectorized_select_decreasing_induction_icmp(ptr nocapture readonly %a, ptr nocapture readonly %b, i64 %rdx.start, i64 %n) {
-; CHECK-LABEL: @not_vectorized_select_decreasing_induction_icmp
+define i64 @not_vectorized_select_decreasing_induction_icmp_const_start(ptr nocapture readonly %a) {
+; CHECK-LABEL: @not_vectorized_select_decreasing_induction_icmp_const_start
+; CHECK-NOT:   vector.body:
+;
+entry:
+  br label %for.body
+
+for.body:                                         ; preds = %entry, %for.body
+  %iv = phi i64 [ 19999, %entry ], [ %dec, %for.body ]
+  %rdx = phi i64 [ 331, %entry ], [ %spec.select, %for.body ]
+  %arrayidx = getelementptr inbounds i64, ptr %a, i64 %iv
+  %0 = load i64, ptr %arrayidx, align 8
+  %cmp = icmp sgt i64 %0, 3
+  %spec.select = select i1 %cmp, i64 %iv, i64 %rdx
+  %dec = add nsw i64 %iv, -1
+  %cmp.not = icmp eq i64 %iv, 0
+  br i1 %cmp.not, label %exit, label %for.body
+
+exit:                                             ; preds = %for.body
+  ret i64 %spec.select
+}
+
+define i64 @not_vectorized_select_decreasing_induction_icmp_non_const_start(ptr nocapture readonly %a, ptr nocapture readonly %b, i64 %rdx.start, i64 %n) {
+; CHECK-LABEL: @not_vectorized_select_decreasing_induction_icmp_non_const_start
 ; CHECK-NOT:   vector.body:
 ;
 entry:


        


More information about the llvm-commits mailing list