[llvm] [LV] Add tests for excluded cases in epiloge tail-folding (PR #217364)

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 24 05:57:26 PDT 2026


================
@@ -74,25 +76,115 @@ exit.2:
   ret i16 1
 }
 
-define i32 @opt_for_size(ptr %p, i32 %n) optsize {
-; CHECK-LABEL: LV: Checking a loop in 'opt_for_size'
-; CHECK: LV: No epilogue to apply tail-folding for.
-; CHECK-NEXT: LV: Fall back to a normal epilogue
+define i32 @opt_for_size(ptr %p, i32 %n, i8 %val) optsize {
+; CHECK-LABEL: Checking a loop in 'opt_for_size'
+; CHECK: remark: <unknown>:0:0: No epilogue to apply tail-folding for. Fall back to a normal epilogue
 ;
 entry:
   br label %for.body
 
 for.body:
   %iv = phi i32 [ 0, %entry ], [ %inc, %for.body ]
-  %arrayidx = getelementptr inbounds i32, ptr %p, i32 %iv
-  %0 = load i32, ptr %arrayidx, align 1
-  %cmp1 = icmp eq i32 %0, 0
-  %sel = select i1 %cmp1, i32 2, i32 1
-  store i32 %sel, ptr %arrayidx, align 1
+  %arrayidx = getelementptr inbounds i8, ptr %p, i32 %iv
+  store i8 %val, ptr %arrayidx, align 1
   %inc = add nsw i32 %iv, 1
   %exitcond = icmp eq i32 %inc, %n
   br i1 %exitcond, label %for.end, label %for.body
 
 for.end:
   ret i32 0
 }
+
+define i32 @low_tc(ptr %p, i8 %val)  {
+; CHECK-LABEL: Checking a loop in 'low_tc'
+; CHECK: remark: <unknown>:0:0: No epilogue to apply tail-folding for. Fall back to a normal epilogue
----------------
david-arm wrote:

See comment in `@opt_for_size`, which I think applies here too?

https://github.com/llvm/llvm-project/pull/217364


More information about the llvm-commits mailing list