[llvm] 5df9112 - Reland "[LoopPredication] Add testcase showing BPI computation. NFC"

Anna Thomas via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 27 18:15:55 PDT 2021


Author: Anna Thomas
Date: 2021-09-27T21:15:46-04:00
New Revision: 5df9112ce35044961b861351100b0c193e48079c

URL: https://github.com/llvm/llvm-project/commit/5df9112ce35044961b861351100b0c193e48079c
DIFF: https://github.com/llvm/llvm-project/commit/5df9112ce35044961b861351100b0c193e48079c.diff

LOG: Reland "[LoopPredication] Add testcase showing BPI computation. NFC"

This relands commit 16a62d4f.
Relanded after fixing CHECK-LINES for opt pipeline output to be more
general (based on failures seen in buildbot).

Added: 
    llvm/test/Transforms/LoopPredication/preserve-bpi.ll

Modified: 
    

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/LoopPredication/preserve-bpi.ll b/llvm/test/Transforms/LoopPredication/preserve-bpi.ll
new file mode 100644
index 0000000000000..a6d1ea508d512
--- /dev/null
+++ b/llvm/test/Transforms/LoopPredication/preserve-bpi.ll
@@ -0,0 +1,65 @@
+; RUN: opt -mtriple=x86_64 -passes='require<scalar-evolution>,require<branch-prob>,loop-mssa(loop-predication,licm,simple-loop-unswitch<nontrivial>,loop-simplifycfg)' -debug-pass-manager -debug-only=branch-prob -S < %s 2>&1 | FileCheck %s
+
+; REQUIRES: asserts
+
+declare void @llvm.experimental.guard(i1, ...)
+
+; CHECK: Running pass: RequireAnalysisPass<llvm::BranchProbabilityAnalysis
+; CHECK-NEXT: Running analysis: BranchProbabilityAnalysis on unsigned_loop_0_to_n_ult_check
+; CHECK-NEXT: Running analysis: PostDominatorTreeAnalysis on unsigned_loop_0_to_n_ult_check
+; CHECK-NEXT: ---- Branch Probability Info : unsigned_loop_0_to_n_ult_check ----
+; CHECK: Running pass: LoopSimplifyPass on unsigned_loop_0_to_n_ult_check
+; CHECK: Running pass: LoopPredicationPass on Loop at depth 1
+; CHECK-NEXT: ---- Branch Probability Info : unsigned_loop_0_to_n_ult_check ----
+; CHECK: Running pass: LICMPass on Loop at depth 1
+; CHECK-NEXT: Running pass: SimpleLoopUnswitchPass on Loop at depth 1
+; CHECK-NEXT: Running pass: LoopPredicationPass on Loop at depth 1
+; CHECK-NEXT: ---- Branch Probability Info : unsigned_loop_0_to_n_ult_check ----
+; CHECK: Running pass: LICMPass on Loop at depth 1
+; CHECK-NEXT: Running pass: SimpleLoopUnswitchPass on Loop at depth 1
+; CHECK-NEXT: Running pass: LoopSimplifyCFGPass on Loop at depth 1
+; CHECK-NEXT: Invalidating analysis: BranchProbabilityAnalysis on unsigned_loop_0_to_n_ult_check
+
+
+define i32 @unsigned_loop_0_to_n_ult_check(i32* %array, i32 %length, i32 %n) {
+entry:
+  %tmp5 = icmp eq i32 %n, 0
+  br i1 %tmp5, label %exit, label %loop.preheader
+
+loop.preheader:                                   ; preds = %entry
+  br label %loop
+
+loop:                                             ; preds = %guarded, %loop.preheader
+  %loop.acc = phi i32 [ %loop.acc.next, %guarded ], [ 0, %loop.preheader ]
+  %i = phi i32 [ %i.next, %guarded ], [ 0, %loop.preheader ]
+  %within.bounds = icmp ult i32 %i, %length
+  %widenable_cond = call i1 @llvm.experimental.widenable.condition()
+  %exiplicit_guard_cond = and i1 %within.bounds, %widenable_cond
+  br i1 %exiplicit_guard_cond, label %guarded, label %deopt, !prof !0
+
+deopt:                                            ; preds = %loop
+  %deoptcall = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ]
+  ret i32 %deoptcall
+
+guarded:                                          ; preds = %loop
+  %i.i64 = zext i32 %i to i64
+  %array.i.ptr = getelementptr inbounds i32, i32* %array, i64 %i.i64
+  %array.i = load i32, i32* %array.i.ptr, align 4
+  %loop.acc.next = add i32 %loop.acc, %array.i
+  %i.next = add nuw i32 %i, 1
+  %continue = icmp ult i32 %i.next, %n
+  br i1 %continue, label %loop, label %exit, !prof !2
+
+exit:                                             ; preds = %guarded, %entry
+  %result = phi i32 [ 0, %entry ], [ %loop.acc.next, %guarded ]
+  ret i32 %result
+}
+
+declare i32 @llvm.experimental.deoptimize.i32(...)
+declare i1 @llvm.experimental.widenable.condition() #0
+
+attributes #0 = { inaccessiblememonly nounwind }
+
+!0 = !{!"branch_weights", i32 1048576, i32 1}
+!1 = !{i32 1, i32 -2147483648}
+!2 = !{!"branch_weights", i32 1024, i32 1}


        


More information about the llvm-commits mailing list