[llvm] 432a12c - [NFC][LoopUnroll] Update test coverage for peeling w/ inequality predicates

Roman Lebedev via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 6 04:09:25 PST 2019


Author: Roman Lebedev
Date: 2019-11-06T15:08:59+03:00
New Revision: 432a12c8037293bd1ff919a82f1d4412772ac534

URL: https://github.com/llvm/llvm-project/commit/432a12c8037293bd1ff919a82f1d4412772ac534
DIFF: https://github.com/llvm/llvm-project/commit/432a12c8037293bd1ff919a82f1d4412772ac534.diff

LOG: [NFC][LoopUnroll] Update test coverage for peeling w/ inequality predicates

Added: 
    

Modified: 
    llvm/test/Transforms/LoopUnroll/peel-loop-conditions.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/LoopUnroll/peel-loop-conditions.ll b/llvm/test/Transforms/LoopUnroll/peel-loop-conditions.ll
index 3d889c69bac4..8c577ecb75cb 100644
--- a/llvm/test/Transforms/LoopUnroll/peel-loop-conditions.ll
+++ b/llvm/test/Transforms/LoopUnroll/peel-loop-conditions.ll
@@ -1,5 +1,5 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
-; RUN: opt < %s -S -loop-unroll -verify-dom-info | FileCheck %s
+; RUN: opt < %s -S -loop-unroll -unroll-peel-max-count=4 -verify-dom-info | FileCheck %s
 
 declare void @f1()
 declare void @f2()
@@ -522,8 +522,6 @@ for.end:
 }
 
 define void @test7(i32 %k) {
-; FIXME: Could simplify loop body by peeling one additional iteration after
-;        i != 3 becomes false
 ; CHECK-LABEL: @test7(
 ; CHECK-NEXT:  for.body.lr.ph:
 ; CHECK-NEXT:    br label [[FOR_BODY:%.*]]
@@ -563,8 +561,6 @@ for.end:
 }
 
 define void @test8(i32 %k) {
-; FIXME: Could simplify loop body by peeling one additional iteration after
-;        i == 3 becomes true.
 ; CHECK-LABEL: @test8(
 ; CHECK-NEXT:  for.body.lr.ph:
 ; CHECK-NEXT:    br label [[FOR_BODY:%.*]]
@@ -779,6 +775,8 @@ if.end:                                           ; preds = %if.then, %for.body
   br i1 %exitcond, label %for.cond.cleanup, label %for.body
 }
 
+; NOTE: here we should only peel the first iteration,
+;       i.e. all calls to sink() must stay in loop.
 define void @test12__peel_first_iter_via_eq_pred(i32 %len) {
 ; CHECK-LABEL: @test12__peel_first_iter_via_eq_pred(
 ; CHECK-NEXT:  entry:
@@ -826,6 +824,8 @@ if.end:                                           ; preds = %if.then, %for.body
   br i1 %exitcond, label %for.cond.cleanup, label %for.body
 }
 
+; NOTE: here we should only peel the first iteration,
+;       i.e. all calls to sink() must stay in loop.
 define void @test13__peel_first_iter_via_ne_pred(i32 %len) {
 ; CHECK-LABEL: @test13__peel_first_iter_via_ne_pred(
 ; CHECK-NEXT:  entry:
@@ -873,6 +873,7 @@ if.end:                                           ; preds = %if.then, %for.body
   br i1 %exitcond, label %for.cond.cleanup, label %for.body
 }
 
+; No peeling is profitable here.
 define void @test15__ivar_mod2_is_1(i32 %len) {
 ; CHECK-LABEL: @test15__ivar_mod2_is_1(
 ; CHECK-NEXT:  entry:
@@ -922,6 +923,7 @@ if.end:                                           ; preds = %if.then, %for.body
   br i1 %exitcond, label %for.cond.cleanup, label %for.body
 }
 
+; No peeling is profitable here.
 define void @test16__ivar_mod2_is_0(i32 %len) {
 ; CHECK-LABEL: @test16__ivar_mod2_is_0(
 ; CHECK-NEXT:  entry:
@@ -971,5 +973,87 @@ if.end:                                           ; preds = %if.then, %for.body
   br i1 %exitcond, label %for.cond.cleanup, label %for.body
 }
 
+; Similar to @test7, we need to peel one extra iteration, and we can't do that
+; as per the -unroll-peel-max-count=4, so this shouldn't be peeled at all.
+define void @test17(i32 %k) {
+; CHECK-LABEL: @test17(
+; CHECK-NEXT:  for.body.lr.ph:
+; CHECK-NEXT:    br label [[FOR_BODY:%.*]]
+; CHECK:       for.body:
+; CHECK-NEXT:    [[I_05:%.*]] = phi i32 [ 0, [[FOR_BODY_LR_PH:%.*]] ], [ [[INC:%.*]], [[FOR_INC:%.*]] ]
+; CHECK-NEXT:    [[CMP1:%.*]] = icmp ne i32 [[I_05]], 4
+; CHECK-NEXT:    br i1 [[CMP1]], label [[IF_THEN:%.*]], label [[FOR_INC]]
+; CHECK:       if.then:
+; CHECK-NEXT:    call void @f1()
+; CHECK-NEXT:    br label [[FOR_INC]]
+; CHECK:       for.inc:
+; CHECK-NEXT:    [[INC]] = add nsw i32 [[I_05]], 1
+; CHECK-NEXT:    [[CMP:%.*]] = icmp slt i32 [[INC]], [[K:%.*]]
+; CHECK-NEXT:    br i1 [[CMP]], label [[FOR_BODY]], label [[FOR_END:%.*]]
+; CHECK:       for.end:
+; CHECK-NEXT:    ret void
+;
+for.body.lr.ph:
+  br label %for.body
+
+for.body:
+  %i.05 = phi i32 [ 0, %for.body.lr.ph ], [ %inc, %for.inc ]
+  %cmp1 = icmp ne i32 %i.05, 4
+  br i1 %cmp1, label %if.then, label %for.inc
+
+if.then:
+  call void @f1()
+  br label %for.inc
+
+for.inc:
+  %inc = add nsw i32 %i.05, 1
+  %cmp = icmp slt i32 %inc, %k
+  br i1 %cmp, label %for.body, label %for.end
+
+for.end:
+  ret void
+}
+
+; Similar to @test8, we need to peel one extra iteration, and we can't do that
+; as per the -unroll-peel-max-count=4, so this shouldn't be peeled at all.
+define void @test18(i32 %k) {
+; CHECK-LABEL: @test18(
+; CHECK-NEXT:  for.body.lr.ph:
+; CHECK-NEXT:    br label [[FOR_BODY:%.*]]
+; CHECK:       for.body:
+; CHECK-NEXT:    [[I_05:%.*]] = phi i32 [ 0, [[FOR_BODY_LR_PH:%.*]] ], [ [[INC:%.*]], [[FOR_INC:%.*]] ]
+; CHECK-NEXT:    [[CMP1:%.*]] = icmp eq i32 [[I_05]], 4
+; CHECK-NEXT:    br i1 [[CMP1]], label [[IF_THEN:%.*]], label [[FOR_INC]]
+; CHECK:       if.then:
+; CHECK-NEXT:    call void @f1()
+; CHECK-NEXT:    br label [[FOR_INC]]
+; CHECK:       for.inc:
+; CHECK-NEXT:    [[INC]] = add nsw i32 [[I_05]], 1
+; CHECK-NEXT:    [[CMP:%.*]] = icmp slt i32 [[INC]], [[K:%.*]]
+; CHECK-NEXT:    br i1 [[CMP]], label [[FOR_BODY]], label [[FOR_END:%.*]]
+; CHECK:       for.end:
+; CHECK-NEXT:    ret void
+;
+for.body.lr.ph:
+  br label %for.body
+
+for.body:
+  %i.05 = phi i32 [ 0, %for.body.lr.ph ], [ %inc, %for.inc ]
+  %cmp1 = icmp eq i32 %i.05, 4
+  br i1 %cmp1, label %if.then, label %for.inc
+
+if.then:
+  call void @f1()
+  br label %for.inc
+
+for.inc:
+  %inc = add nsw i32 %i.05, 1
+  %cmp = icmp slt i32 %inc, %k
+  br i1 %cmp, label %for.body, label %for.end
+
+for.end:
+  ret void
+}
+
 declare void @init()
 declare void @sink()


        


More information about the llvm-commits mailing list