[llvm] f1d8e46 - Clarify invariants of software pipelining hooks

Thomas Preud'homme via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 29 03:44:15 PDT 2022


Author: Thomas Preud'homme
Date: 2022-03-29T11:44:10+01:00
New Revision: f1d8e46258c6a08ca1a375dc9670dd5581d6cf65

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

LOG: Clarify invariants of software pipelining hooks

PowerPC backend relies on each pair of prologue/epilogue of a software
pipelined loop to correspond to a single iteration a the loop through
its use of the BDZ instruction to skip inner prologues/epilogues and
loop kernel. However the interface does not make it clear that it is a
valid way to check that the trip count is big enough to execute inner
prologues/epilogues and kernel loop.

The API also does not specify in which order of prologues the
createTripCountGreaterCondition() hook is being called. Knowing that it
starts with the last/innermost prologues can help recording some
information when createTripCountGreaterCondition() is first executed and
reuse it in setPreheader() or adjustTripCount().

This commit documents both aspects.

Reviewed By: jmolloy

Differential Revision: https://reviews.llvm.org/D122642

Added: 
    

Modified: 
    llvm/include/llvm/CodeGen/TargetInstrInfo.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/CodeGen/TargetInstrInfo.h b/llvm/include/llvm/CodeGen/TargetInstrInfo.h
index 12cd21617b0d4..d05493386bdf7 100644
--- a/llvm/include/llvm/CodeGen/TargetInstrInfo.h
+++ b/llvm/include/llvm/CodeGen/TargetInstrInfo.h
@@ -734,12 +734,16 @@ class TargetInstrInfo : public MCInstrInfo {
     virtual bool shouldIgnoreForPipelining(const MachineInstr *MI) const = 0;
 
     /// Create a condition to determine if the trip count of the loop is greater
-    /// than TC.
+    /// than TC, where TC is always one more than for the previous prologue or
+    /// 0 if this is being called for the outermost prologue.
     ///
     /// If the trip count is statically known to be greater than TC, return
     /// true. If the trip count is statically known to be not greater than TC,
     /// return false. Otherwise return nullopt and fill out Cond with the test
     /// condition.
+    ///
+    /// Note: This hook is guaranteed to be called from the innermost to the
+    /// outermost prologue of the loop being software pipelined.
     virtual Optional<bool>
     createTripCountGreaterCondition(int TC, MachineBasicBlock &MBB,
                                     SmallVectorImpl<MachineOperand> &Cond) = 0;


        


More information about the llvm-commits mailing list