[llvm] 138d5c7 - [NFC][SCEV] Add more tests for umin_seq with redundant operands

Roman Lebedev via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 11 06:52:04 PST 2022


Author: Roman Lebedev
Date: 2022-01-11T17:51:51+03:00
New Revision: 138d5c750ba278108ff64b5543644b722642cabc

URL: https://github.com/llvm/llvm-project/commit/138d5c750ba278108ff64b5543644b722642cabc
DIFF: https://github.com/llvm/llvm-project/commit/138d5c750ba278108ff64b5543644b722642cabc.diff

LOG: [NFC][SCEV] Add more tests for umin_seq with redundant operands

Added: 
    

Modified: 
    llvm/test/Analysis/ScalarEvolution/exit-count-select-safe.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Analysis/ScalarEvolution/exit-count-select-safe.ll b/llvm/test/Analysis/ScalarEvolution/exit-count-select-safe.ll
index 1050f259d363..706a2001be17 100644
--- a/llvm/test/Analysis/ScalarEvolution/exit-count-select-safe.ll
+++ b/llvm/test/Analysis/ScalarEvolution/exit-count-select-safe.ll
@@ -162,6 +162,116 @@ exit:
   ret i32 %i
 }
 
+define i32 @logical_or_3ops_redundant_uminseq_operand(i32 %n, i32 %m, i32 %k) {
+; CHECK-LABEL: 'logical_or_3ops_redundant_uminseq_operand'
+; CHECK-NEXT:  Classifying expressions for: @logical_or_3ops_redundant_uminseq_operand
+; CHECK-NEXT:    %i = phi i32 [ 0, %entry ], [ %i.next, %loop ]
+; CHECK-NEXT:    --> {0,+,1}<%loop> U: full-set S: full-set Exits: ((%n umin %m) umin_seq %n umin_seq %k) LoopDispositions: { %loop: Computable }
+; CHECK-NEXT:    %i.next = add i32 %i, 1
+; CHECK-NEXT:    --> {1,+,1}<%loop> U: full-set S: full-set Exits: (1 + ((%n umin %m) umin_seq %n umin_seq %k)) LoopDispositions: { %loop: Computable }
+; CHECK-NEXT:    %umin = call i32 @llvm.umin.i32(i32 %n, i32 %m)
+; CHECK-NEXT:    --> (%n umin %m) U: full-set S: full-set Exits: (%n umin %m) LoopDispositions: { %loop: Invariant }
+; CHECK-NEXT:    %cond_p3 = select i1 %cond_p0, i1 true, i1 %cond_p1
+; CHECK-NEXT:    --> %cond_p3 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
+; CHECK-NEXT:    %cond = select i1 %cond_p3, i1 true, i1 %cond_p2
+; CHECK-NEXT:    --> %cond U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
+; CHECK-NEXT:  Determining loop execution counts for: @logical_or_3ops_redundant_uminseq_operand
+; CHECK-NEXT:  Loop %loop: backedge-taken count is ((%n umin %m) umin_seq %n umin_seq %k)
+; CHECK-NEXT:  Loop %loop: max backedge-taken count is -1
+; CHECK-NEXT:  Loop %loop: Predicated backedge-taken count is ((%n umin %m) umin_seq %n umin_seq %k)
+; CHECK-NEXT:   Predicates:
+; CHECK:       Loop %loop: Trip multiple is 1
+;
+entry:
+  br label %loop
+loop:
+  %i = phi i32 [0, %entry], [%i.next, %loop]
+  %i.next = add i32 %i, 1
+  %umin = call i32 @llvm.umin.i32(i32 %n, i32 %m)
+  %cond_p0 = icmp uge i32 %i, %umin
+  %cond_p1 = icmp uge i32 %i, %n
+  %cond_p2 = icmp uge i32 %i, %k
+  %cond_p3 = select i1 %cond_p0, i1 true, i1 %cond_p1
+  %cond = select i1 %cond_p3, i1 true, i1 %cond_p2
+  br i1 %cond, label %exit, label %loop
+exit:
+  ret i32 %i
+}
+
+define i32 @logical_or_3ops_redundant_umin_operand(i32 %n, i32 %m, i32 %k) {
+; CHECK-LABEL: 'logical_or_3ops_redundant_umin_operand'
+; CHECK-NEXT:  Classifying expressions for: @logical_or_3ops_redundant_umin_operand
+; CHECK-NEXT:    %i = phi i32 [ 0, %entry ], [ %i.next, %loop ]
+; CHECK-NEXT:    --> {0,+,1}<%loop> U: full-set S: full-set Exits: (%n umin_seq %k umin_seq (%n umin %m)) LoopDispositions: { %loop: Computable }
+; CHECK-NEXT:    %i.next = add i32 %i, 1
+; CHECK-NEXT:    --> {1,+,1}<%loop> U: full-set S: full-set Exits: (1 + (%n umin_seq %k umin_seq (%n umin %m))) LoopDispositions: { %loop: Computable }
+; CHECK-NEXT:    %umin = call i32 @llvm.umin.i32(i32 %n, i32 %m)
+; CHECK-NEXT:    --> (%n umin %m) U: full-set S: full-set Exits: (%n umin %m) LoopDispositions: { %loop: Invariant }
+; CHECK-NEXT:    %cond_p3 = select i1 %cond_p0, i1 true, i1 %cond_p1
+; CHECK-NEXT:    --> %cond_p3 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
+; CHECK-NEXT:    %cond = select i1 %cond_p3, i1 true, i1 %cond_p2
+; CHECK-NEXT:    --> %cond U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
+; CHECK-NEXT:  Determining loop execution counts for: @logical_or_3ops_redundant_umin_operand
+; CHECK-NEXT:  Loop %loop: backedge-taken count is (%n umin_seq %k umin_seq (%n umin %m))
+; CHECK-NEXT:  Loop %loop: max backedge-taken count is -1
+; CHECK-NEXT:  Loop %loop: Predicated backedge-taken count is (%n umin_seq %k umin_seq (%n umin %m))
+; CHECK-NEXT:   Predicates:
+; CHECK:       Loop %loop: Trip multiple is 1
+;
+entry:
+  br label %loop
+loop:
+  %i = phi i32 [0, %entry], [%i.next, %loop]
+  %i.next = add i32 %i, 1
+  %umin = call i32 @llvm.umin.i32(i32 %n, i32 %m)
+  %cond_p0 = icmp uge i32 %i, %n
+  %cond_p1 = icmp uge i32 %i, %k
+  %cond_p2 = icmp uge i32 %i, %umin
+  %cond_p3 = select i1 %cond_p0, i1 true, i1 %cond_p1
+  %cond = select i1 %cond_p3, i1 true, i1 %cond_p2
+  br i1 %cond, label %exit, label %loop
+exit:
+  ret i32 %i
+}
+define i32 @logical_or_4ops_redundant_operand_across_umins(i32 %n, i32 %m, i32 %k, i32 %q) {
+; CHECK-LABEL: 'logical_or_4ops_redundant_operand_across_umins'
+; CHECK-NEXT:  Classifying expressions for: @logical_or_4ops_redundant_operand_across_umins
+; CHECK-NEXT:    %i = phi i32 [ 0, %entry ], [ %i.next, %loop ]
+; CHECK-NEXT:    --> {0,+,1}<%loop> U: full-set S: full-set Exits: ((%n umin %m) umin_seq %k umin_seq (%n umin %q)) LoopDispositions: { %loop: Computable }
+; CHECK-NEXT:    %i.next = add i32 %i, 1
+; CHECK-NEXT:    --> {1,+,1}<%loop> U: full-set S: full-set Exits: (1 + ((%n umin %m) umin_seq %k umin_seq (%n umin %q))) LoopDispositions: { %loop: Computable }
+; CHECK-NEXT:    %umin = call i32 @llvm.umin.i32(i32 %n, i32 %m)
+; CHECK-NEXT:    --> (%n umin %m) U: full-set S: full-set Exits: (%n umin %m) LoopDispositions: { %loop: Invariant }
+; CHECK-NEXT:    %umin2 = call i32 @llvm.umin.i32(i32 %n, i32 %q)
+; CHECK-NEXT:    --> (%n umin %q) U: full-set S: full-set Exits: (%n umin %q) LoopDispositions: { %loop: Invariant }
+; CHECK-NEXT:    %cond_p3 = select i1 %cond_p0, i1 true, i1 %cond_p1
+; CHECK-NEXT:    --> %cond_p3 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
+; CHECK-NEXT:    %cond = select i1 %cond_p3, i1 true, i1 %cond_p2
+; CHECK-NEXT:    --> %cond U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
+; CHECK-NEXT:  Determining loop execution counts for: @logical_or_4ops_redundant_operand_across_umins
+; CHECK-NEXT:  Loop %loop: backedge-taken count is ((%n umin %m) umin_seq %k umin_seq (%n umin %q))
+; CHECK-NEXT:  Loop %loop: max backedge-taken count is -1
+; CHECK-NEXT:  Loop %loop: Predicated backedge-taken count is ((%n umin %m) umin_seq %k umin_seq (%n umin %q))
+; CHECK-NEXT:   Predicates:
+; CHECK:       Loop %loop: Trip multiple is 1
+;
+entry:
+  br label %loop
+loop:
+  %i = phi i32 [0, %entry], [%i.next, %loop]
+  %i.next = add i32 %i, 1
+  %umin = call i32 @llvm.umin.i32(i32 %n, i32 %m)
+  %umin2 = call i32 @llvm.umin.i32(i32 %n, i32 %q)
+  %cond_p0 = icmp uge i32 %i, %umin
+  %cond_p1 = icmp uge i32 %i, %k
+  %cond_p2 = icmp uge i32 %i, %umin2
+  %cond_p3 = select i1 %cond_p0, i1 true, i1 %cond_p1
+  %cond = select i1 %cond_p3, i1 true, i1 %cond_p2
+  br i1 %cond, label %exit, label %loop
+exit:
+  ret i32 %i
+}
+
 define i32 @computeSCEVAtScope(i32 %d.0) {
 ; CHECK-LABEL: 'computeSCEVAtScope'
 ; CHECK-NEXT:  Classifying expressions for: @computeSCEVAtScope
@@ -231,3 +341,5 @@ for.body5:                                        ; preds = %for.cond4
   %inc8 = add i32 %f.1, 1
   br label %for.cond4
 }
+
+declare i32 @llvm.umin.i32(i32, i32)


        


More information about the llvm-commits mailing list