[PATCH] D156124: LoopVectorize/iv-select-cmp: add tests for truncated IV

Ramkumar Ramachandra via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 26 08:14:40 PDT 2023


artagnon updated this revision to Diff 544379.
artagnon added a comment.

Preserve newline at end of file.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156124/new/

https://reviews.llvm.org/D156124

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


Index: llvm/test/Transforms/LoopVectorize/iv-select-cmp.ll
===================================================================
--- llvm/test/Transforms/LoopVectorize/iv-select-cmp.ll
+++ llvm/test/Transforms/LoopVectorize/iv-select-cmp.ll
@@ -188,6 +188,56 @@
 
 ; Negative tests
 
+define i32 @not_vectorized_select_icmp_const_truncated_iv(ptr nocapture readonly %a, i64 %n) {
+; CHECK-LABEL: define i32 @not_vectorized_select_icmp_const_truncated_iv
+; CHECK-NOT:   vector.body:
+;
+entry:
+  %cmp.sgt = icmp sgt i64 %n, 0
+  br i1 %cmp.sgt, label %for.body, label %exit
+
+for.body:                                         ; preds = %entry, %for.body
+  %iv = phi i64 [ 0, %entry ], [ %inc, %for.body ]
+  %rdx = phi i32 [ 331, %entry ], [ %spec.select, %for.body ]
+  %arrayidx = getelementptr inbounds i32, ptr %a, i64 %iv
+  %0 = load i32, ptr %arrayidx, align 4
+  %cmp = icmp sgt i32 %0, 3
+  %1 = trunc i64 %iv to i32
+  %spec.select = select i1 %cmp, i32 %1, i32 %rdx
+  %inc = add nuw nsw i64 %iv, 1
+  %exitcond.not = icmp eq i64 %inc, %n
+  br i1 %exitcond.not, label %exit, label %for.body
+
+exit:                                             ; preds = %for.body, %entry
+  %rdx.lcssa = phi i32 [ 331, %entry ], [ %spec.select, %for.body ]
+  ret i32 %rdx.lcssa
+}
+
+define i32 @not_vectorized_select_icmp_const_truncated_iv_unsigned_loop_guard(ptr nocapture readonly %a, i64 %n) {
+; CHECK-LABEL: define i32 @not_vectorized_select_icmp_const_truncated_iv_unsigned_loop_guard
+; CHECK-NOT:   vector.body:
+;
+entry:
+  %cmp.not = icmp eq i64 %n, 0
+  br i1 %cmp.not, label %exit, label %for.body
+
+for.body:                                         ; preds = %entry, %for.body
+  %iv = phi i64 [ 0, %entry ], [ %inc, %for.body ]
+  %rdx = phi i32 [ 331, %entry ], [ %spec.select, %for.body ]
+  %arrayidx = getelementptr inbounds i32, ptr %a, i64 %iv
+  %0 = load i32, ptr %arrayidx, align 4
+  %cmp = icmp sgt i32 %0, 3
+  %1 = trunc i64 %iv to i32
+  %spec.select = select i1 %cmp, i32 %1, i32 %rdx
+  %inc = add nuw nsw i64 %iv, 1
+  %exitcond.not = icmp eq i64 %inc, %n
+  br i1 %exitcond.not, label %exit, label %for.body
+
+exit:                                             ; preds = %for.body, %entry
+  %rdx.lcssa = phi i32 [ 331, %entry ], [ %spec.select, %for.body ]
+  ret i32 %rdx.lcssa
+}
+
 define float @not_vectorized_select_float_induction_icmp(ptr nocapture readonly %a, ptr nocapture readonly %b, float %rdx.start, i64 %n) {
 ; CHECK-LABEL: @not_vectorized_select_float_induction_icmp
 ; CHECK-NOT:   vector.body:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156124.544379.patch
Type: text/x-patch
Size: 2548 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230726/593c34f3/attachment.bin>


More information about the llvm-commits mailing list