[llvm] [LoopUnroll] Enhance the use of Optimization Remarks and `LLVM_DEBUG` (PR #178476)
Justin Fargnoli via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 20 12:51:46 PST 2026
================
@@ -807,38 +821,83 @@ static std::optional<unsigned>
shouldPragmaUnroll(Loop *L, const PragmaInfo &PInfo,
const unsigned TripMultiple, const unsigned TripCount,
unsigned MaxTripCount, const UnrollCostEstimator UCE,
- const TargetTransformInfo::UnrollingPreferences &UP) {
+ const TargetTransformInfo::UnrollingPreferences &UP,
+ OptimizationRemarkEmitter *ORE) {
// Using unroll pragma
// 1st priority is unroll count set by "unroll-count" option.
if (PInfo.UserUnrollCount) {
if (UP.AllowRemainder &&
- UCE.getUnrolledLoopSize(UP, (unsigned)UnrollCount) < UP.Threshold)
+ UCE.getUnrolledLoopSize(UP, (unsigned)UnrollCount) < UP.Threshold) {
+ LLVM_DEBUG(dbgs().indent(2) << "Unrolling with user-specified count: "
+ << UnrollCount << "\n");
return (unsigned)UnrollCount;
+ }
+ LLVM_DEBUG(dbgs().indent(2)
+ << "Not unrolling with user count " << UnrollCount << ": "
+ << (!UP.AllowRemainder ? "remainder not allowed"
+ : "exceeds threshold")
+ << ".\n");
}
// 2nd priority is unroll count set by pragma.
if (PInfo.PragmaCount > 0) {
- if ((UP.AllowRemainder || (TripMultiple % PInfo.PragmaCount == 0)))
+ if ((UP.AllowRemainder || (TripMultiple % PInfo.PragmaCount == 0))) {
+ LLVM_DEBUG(dbgs().indent(2) << "Unrolling with pragma count: "
+ << PInfo.PragmaCount << "\n");
----------------
justinfargnoli wrote:
Let's make all additional debug messages a separate PR.
https://github.com/llvm/llvm-project/pull/178476
More information about the llvm-commits
mailing list