https://github.com/kasuga-fj updated https://github.com/llvm/llvm-project/pull/193478
>From 9a454dd4aa160273a36e69f2bf80d6cd7b627371 Mon Sep 17 00:00:00 2001 From: Ryotaro Kasuga <[email protected]> Date: Wed, 22 Apr 2026 10:05:54 +0000 Subject: [PATCH 1/3] [LoopInterchange] Disable LoopCacheAnalysis-based heuristic by default --- llvm/lib/Transforms/Scalar/LoopInterchange.cpp | 3 +-- .../LoopInterchange/delay-cachecost-calculation.ll | 2 +- .../Transforms/LoopInterchange/lcssa-phi-outer-latch.ll | 2 +- .../loop-interchange-optimization-remarks.ll | 2 +- llvm/test/Transforms/LoopInterchange/perserve-lcssa.ll | 2 +- llvm/test/Transforms/LoopInterchange/pr57148.ll | 2 +- .../LoopInterchange/profitability-vectorization.ll | 6 +++--- 7 files changed, 9 insertions(+), 10 deletions(-) diff --git a/llvm/lib/Transforms/Scalar/LoopInterchange.cpp b/llvm/lib/Transforms/Scalar/LoopInterchange.cpp index c364e235b408e..8c793e81a4f34 100644 --- a/llvm/lib/Transforms/Scalar/LoopInterchange.cpp +++ b/llvm/lib/Transforms/Scalar/LoopInterchange.cpp @@ -108,8 +108,7 @@ static cl::list<RuleTy> Profitabilities( cl::Hidden, cl::desc("List of profitability heuristics to be used. They are applied in " "the given order"), - cl::list_init<RuleTy>({RuleTy::PerLoopCacheAnalysis, - RuleTy::PerInstrOrderCost, + cl::list_init<RuleTy>({RuleTy::PerInstrOrderCost, RuleTy::ForVectorization}), cl::values(clEnumValN(RuleTy::PerLoopCacheAnalysis, "cache", "Prioritize loop cache cost"), diff --git a/llvm/test/Transforms/LoopInterchange/delay-cachecost-calculation.ll b/llvm/test/Transforms/LoopInterchange/delay-cachecost-calculation.ll index 14403469440c3..5e90abc75e43b 100644 --- a/llvm/test/Transforms/LoopInterchange/delay-cachecost-calculation.ll +++ b/llvm/test/Transforms/LoopInterchange/delay-cachecost-calculation.ll @@ -1,6 +1,6 @@ ; REQUIRES: asserts -; RUN: opt -passes=loop-interchange -debug -disable-output %s 2>&1 | FileCheck %s +; RUN: opt -passes=loop-interchange -debug -disable-output -loop-interchange-profitabilities=cache %s 2>&1 | FileCheck %s @A = global [16 x [16 x i32]] zeroinitializer diff --git a/llvm/test/Transforms/LoopInterchange/lcssa-phi-outer-latch.ll b/llvm/test/Transforms/LoopInterchange/lcssa-phi-outer-latch.ll index 92ce3288b4529..925a7b7bcda0d 100644 --- a/llvm/test/Transforms/LoopInterchange/lcssa-phi-outer-latch.ll +++ b/llvm/test/Transforms/LoopInterchange/lcssa-phi-outer-latch.ll @@ -1,5 +1,5 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 6 -; RUN: opt < %s -passes=loop-interchange -cache-line-size=64 -verify-dom-info -verify-loop-info -verify-scev -verify-loop-lcssa -S | FileCheck %s +; RUN: opt < %s -passes=loop-interchange -loop-interchange-profitabilities=ignore -verify-dom-info -verify-loop-info -verify-scev -verify-loop-lcssa -S | FileCheck %s ; This test is checking that blocks outer.body and outer.latch, where outer.body is the exit ; block of the inner loop and outer.latch the latch of the outer loop, correctly diff --git a/llvm/test/Transforms/LoopInterchange/loop-interchange-optimization-remarks.ll b/llvm/test/Transforms/LoopInterchange/loop-interchange-optimization-remarks.ll index 14836ba73433d..7061fe4749cc1 100644 --- a/llvm/test/Transforms/LoopInterchange/loop-interchange-optimization-remarks.ll +++ b/llvm/test/Transforms/LoopInterchange/loop-interchange-optimization-remarks.ll @@ -87,7 +87,7 @@ for.end19: ; DELIN-NEXT: Name: InterchangeNotProfitable ; DELIN-NEXT: Function: test01 ; DELIN-NEXT: Args: -; DELIN-NEXT: - String: Interchanging loops is not considered to improve cache locality nor vectorization. +; DELIN-NEXT: - String: Insufficient information to calculate the cost of loop for interchange. ; DELIN-NEXT: ... ;;--------------------------------------Test case 02------------------------------------ diff --git a/llvm/test/Transforms/LoopInterchange/perserve-lcssa.ll b/llvm/test/Transforms/LoopInterchange/perserve-lcssa.ll index 11d79c0d86f2e..9fc70b16acbdc 100644 --- a/llvm/test/Transforms/LoopInterchange/perserve-lcssa.ll +++ b/llvm/test/Transforms/LoopInterchange/perserve-lcssa.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -passes=loop-interchange -cache-line-size=64 -loop-interchange-threshold=-100 -verify-loop-lcssa -S | FileCheck %s +; RUN: opt < %s -passes=loop-interchange -loop-interchange-profitabilities=ignore -loop-interchange-threshold=-100 -verify-loop-lcssa -S | FileCheck %s ; Test case for PR41725. The induction variables in the latches escape the ; loops and we must move some PHIs around. diff --git a/llvm/test/Transforms/LoopInterchange/pr57148.ll b/llvm/test/Transforms/LoopInterchange/pr57148.ll index 809c41c1713c2..707b3da78695b 100644 --- a/llvm/test/Transforms/LoopInterchange/pr57148.ll +++ b/llvm/test/Transforms/LoopInterchange/pr57148.ll @@ -1,5 +1,5 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 6 -; RUN: opt < %s -passes=loop-interchange -cache-line-size=4 -loop-interchange-threshold=-100 -verify-dom-info -verify-loop-info -verify-scev -verify-loop-lcssa -S | FileCheck %s +; RUN: opt < %s -passes=loop-interchange -loop-interchange-profitabilities=cache -loop-interchange-threshold=-100 -verify-dom-info -verify-loop-info -verify-scev -verify-loop-lcssa -S | FileCheck %s ; Make sure the loops are in LCSSA form after loop interchange, ; and loop interchange does not hit assertion errors and crash. diff --git a/llvm/test/Transforms/LoopInterchange/profitability-vectorization.ll b/llvm/test/Transforms/LoopInterchange/profitability-vectorization.ll index 90813593b8500..38619a64219d4 100644 --- a/llvm/test/Transforms/LoopInterchange/profitability-vectorization.ll +++ b/llvm/test/Transforms/LoopInterchange/profitability-vectorization.ll @@ -1,9 +1,9 @@ ; RUN: opt < %s -passes=loop-interchange -cache-line-size=64 \ -; RUN: -pass-remarks-output=%t -disable-output +; RUN: -pass-remarks-output=%t -disable-output -loop-interchange-profitabilities=instorder ; RUN: FileCheck -input-file %t --check-prefix=PROFIT-CACHE %s ; RUN: opt < %s -passes=loop-interchange -cache-line-size=64 \ -; RUN: -pass-remarks-output=%t -disable-output -loop-interchange-profitabilities=vectorize,cache,instorder +; RUN: -pass-remarks-output=%t -disable-output -loop-interchange-profitabilities=vectorize ; RUN: FileCheck -input-file %t --check-prefix=PROFIT-VEC %s @A = dso_local global [256 x [256 x float]] zeroinitializer @@ -27,7 +27,7 @@ ; PROFIT-CACHE-NEXT: Name: InterchangeNotProfitable ; PROFIT-CACHE-NEXT: Function: f ; PROFIT-CACHE-NEXT: Args: -; PROFIT-CACHE-NEXT: - String: Interchanging loops is not considered to improve cache locality nor vectorization. +; PROFIT-CACHE-NEXT: - String: Insufficient information to calculate the cost of loop for interchange. ; PROFIT-CACHE-NEXT: ... ; PROFIT-VEC: --- !Passed >From 45fe6494199ec9df67b644e544d23526263b8d1e Mon Sep 17 00:00:00 2001 From: Ryotaro Kasuga <[email protected]> Date: Thu, 23 Apr 2026 00:30:35 +0900 Subject: [PATCH 2/3] address review comment --- .../Transforms/LoopInterchange/profitability-vectorization.ll | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llvm/test/Transforms/LoopInterchange/profitability-vectorization.ll b/llvm/test/Transforms/LoopInterchange/profitability-vectorization.ll index 38619a64219d4..be7d8c9837c75 100644 --- a/llvm/test/Transforms/LoopInterchange/profitability-vectorization.ll +++ b/llvm/test/Transforms/LoopInterchange/profitability-vectorization.ll @@ -3,7 +3,7 @@ ; RUN: FileCheck -input-file %t --check-prefix=PROFIT-CACHE %s ; RUN: opt < %s -passes=loop-interchange -cache-line-size=64 \ -; RUN: -pass-remarks-output=%t -disable-output -loop-interchange-profitabilities=vectorize +; RUN: -pass-remarks-output=%t -disable-output -loop-interchange-profitabilities=vectorize,cache,instorder ; RUN: FileCheck -input-file %t --check-prefix=PROFIT-VEC %s @A = dso_local global [256 x [256 x float]] zeroinitializer >From 93ea5b2c2bf4ce5e97a9111130f17cca44ad87a7 Mon Sep 17 00:00:00 2001 From: Ryotaro Kasuga <[email protected]> Date: Fri, 15 May 2026 14:35:07 +0000 Subject: [PATCH 3/3] fix test --- .../LoopInterchange/loop-interchange-optimization-remarks.ll | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/llvm/test/Transforms/LoopInterchange/loop-interchange-optimization-remarks.ll b/llvm/test/Transforms/LoopInterchange/loop-interchange-optimization-remarks.ll index 7061fe4749cc1..22b6efee6e11e 100644 --- a/llvm/test/Transforms/LoopInterchange/loop-interchange-optimization-remarks.ll +++ b/llvm/test/Transforms/LoopInterchange/loop-interchange-optimization-remarks.ll @@ -7,7 +7,8 @@ ; RUN: opt < %s -passes=loop-interchange -cache-line-size=64 -verify-dom-info -verify-loop-info \ ; RUN: -pass-remarks-output=%t -pass-remarks-missed='loop-interchange' \ -; RUN: -pass-remarks='loop-interchange' -S -da-disable-delinearization-checks +; RUN: -pass-remarks='loop-interchange' -S -da-disable-delinearization-checks \ +; RUN: -loop-interchange-profitabilities=cache ; RUN: cat %t | FileCheck --check-prefix=DELIN %s @A = common global [100 x [100 x i32]] zeroinitializer @@ -87,7 +88,7 @@ for.end19: ; DELIN-NEXT: Name: InterchangeNotProfitable ; DELIN-NEXT: Function: test01 ; DELIN-NEXT: Args: -; DELIN-NEXT: - String: Insufficient information to calculate the cost of loop for interchange. +; DELIN-NEXT: - String: Interchanging loops is not considered to improve cache locality nor vectorizatio ; DELIN-NEXT: ... ;;--------------------------------------Test case 02------------------------------------ _______________________________________________ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
