[llvm-branch-commits] [llvm] [LoopInterchange] Relax legality check to accept more patterns (PR #193480)

Ryotaro Kasuga via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu May 21 03:57:23 PDT 2026


https://github.com/kasuga-fj updated https://github.com/llvm/llvm-project/pull/193480

>From 0ce2916c9c541dd88ebce1298c8aea0163f91587 Mon Sep 17 00:00:00 2001
From: Ryotaro Kasuga <kasuga.ryotaro at fujitsu.com>
Date: Tue, 21 Apr 2026 14:45:28 +0000
Subject: [PATCH] [LoopInterchange] Relax legality check to accept more
 patterns

---
 .../lib/Transforms/Scalar/LoopInterchange.cpp |  15 ++
 .../LoopInterchange/dependency-all-eq.ll      | 145 +++++++++++++-----
 .../LoopInterchange/inner-only-reductions.ll  |  10 +-
 ...most-latch-uses-values-in-middle-header.ll |   8 -
 .../LoopInterchange/large-nested-6d.ll        |   8 +-
 .../LoopInterchange/legality-check.ll         |   9 +-
 .../pr43176-move-to-new-latch.ll              |  14 +-
 7 files changed, 140 insertions(+), 69 deletions(-)

diff --git a/llvm/lib/Transforms/Scalar/LoopInterchange.cpp b/llvm/lib/Transforms/Scalar/LoopInterchange.cpp
index e4536a3f4da69..614cd17dd9cb0 100644
--- a/llvm/lib/Transforms/Scalar/LoopInterchange.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopInterchange.cpp
@@ -376,6 +376,21 @@ static bool isLegalToInterChangeLoops(CharMatrix &DepMatrix,
     if (isLexicographicallyPositive(Cur, 0, OuterLoopId) == true)
       continue;
 
+    // For the adjacent loops, if at least one of their direction is '=' or
+    // 'I', interchanging them is legal regardless of the diction of the other.
+    // This check can handle the case like [* =], which will appear in the code
+    // like:
+    //
+    //   for (int repeat = 0; repeat < N; repeat++)
+    //     for (int i = 0; i < N; i++)
+    //       A[i] = ...;
+    //
+    if (OuterLoopId + 1 == InnerLoopId) {
+      auto IsEqualOrIndep = [](char C) { return C == '=' || C == 'I'; };
+      if (IsEqualOrIndep(Cur[OuterLoopId]) || IsEqualOrIndep(Cur[InnerLoopId]))
+        continue;
+    }
+
     // Check if the direction vector is lexicographically positive (or zero)
     // for both before/after exchanged. Ignore the last element because it
     // doesn't affect the legality.
diff --git a/llvm/test/Transforms/LoopInterchange/dependency-all-eq.ll b/llvm/test/Transforms/LoopInterchange/dependency-all-eq.ll
index 7c5dd5489ef1b..489dd88ca48c7 100644
--- a/llvm/test/Transforms/LoopInterchange/dependency-all-eq.ll
+++ b/llvm/test/Transforms/LoopInterchange/dependency-all-eq.ll
@@ -13,26 +13,57 @@
 ;
 
 define void @all_eq(ptr %A) {
-; CHECK-LABEL: define void @all_eq(
-; CHECK-SAME: ptr [[A:%.*]]) {
-; CHECK-NEXT:  [[ENTRY:.*]]:
-; CHECK-NEXT:    br label %[[LOOP_I_HEADER:.*]]
-; CHECK:       [[LOOP_I_HEADER]]:
-; CHECK-NEXT:    [[I:%.*]] = phi i64 [ 0, %[[ENTRY]] ], [ [[I_INC:%.*]], %[[LOOP_I_LATCH:.*]] ]
-; CHECK-NEXT:    br label %[[LOOP_J:.*]]
-; CHECK:       [[LOOP_J]]:
-; CHECK-NEXT:    [[J:%.*]] = phi i64 [ 0, %[[LOOP_I_HEADER]] ], [ [[J_INC:%.*]], %[[LOOP_J]] ]
-; CHECK-NEXT:    [[GEP:%.*]] = getelementptr i8, ptr [[A]], i64 [[J]]
-; CHECK-NEXT:    store i8 0, ptr [[GEP]], align 1
-; CHECK-NEXT:    [[J_INC]] = add i64 [[J]], 1
-; CHECK-NEXT:    [[EC_J:%.*]] = icmp eq i64 [[J_INC]], 100
-; CHECK-NEXT:    br i1 [[EC_J]], label %[[LOOP_I_LATCH]], label %[[LOOP_J]]
-; CHECK:       [[LOOP_I_LATCH]]:
-; CHECK-NEXT:    [[I_INC]] = add i64 [[I]], 1
-; CHECK-NEXT:    [[EC_I:%.*]] = icmp eq i64 [[I_INC]], 100
-; CHECK-NEXT:    br i1 [[EC_I]], label %[[EXIT:.*]], label %[[LOOP_I_HEADER]]
-; CHECK:       [[EXIT]]:
-; CHECK-NEXT:    ret void
+; CHECK-PROFIT-INSTORDER-LABEL: define void @all_eq(
+; CHECK-PROFIT-INSTORDER-SAME: ptr [[A:%.*]]) {
+; CHECK-PROFIT-INSTORDER-NEXT:  [[ENTRY:.*]]:
+; CHECK-PROFIT-INSTORDER-NEXT:    br label %[[LOOP_I_HEADER:.*]]
+; CHECK-PROFIT-INSTORDER:       [[LOOP_I_HEADER]]:
+; CHECK-PROFIT-INSTORDER-NEXT:    [[I:%.*]] = phi i64 [ 0, %[[ENTRY]] ], [ [[I_INC:%.*]], %[[LOOP_I_LATCH:.*]] ]
+; CHECK-PROFIT-INSTORDER-NEXT:    br label %[[LOOP_J:.*]]
+; CHECK-PROFIT-INSTORDER:       [[LOOP_J]]:
+; CHECK-PROFIT-INSTORDER-NEXT:    [[J:%.*]] = phi i64 [ 0, %[[LOOP_I_HEADER]] ], [ [[J_INC:%.*]], %[[LOOP_J]] ]
+; CHECK-PROFIT-INSTORDER-NEXT:    [[GEP:%.*]] = getelementptr i8, ptr [[A]], i64 [[J]]
+; CHECK-PROFIT-INSTORDER-NEXT:    store i8 0, ptr [[GEP]], align 1
+; CHECK-PROFIT-INSTORDER-NEXT:    [[J_INC]] = add i64 [[J]], 1
+; CHECK-PROFIT-INSTORDER-NEXT:    [[EC_J:%.*]] = icmp eq i64 [[J_INC]], 100
+; CHECK-PROFIT-INSTORDER-NEXT:    br i1 [[EC_J]], label %[[LOOP_I_LATCH]], label %[[LOOP_J]]
+; CHECK-PROFIT-INSTORDER:       [[LOOP_I_LATCH]]:
+; CHECK-PROFIT-INSTORDER-NEXT:    [[I_INC]] = add i64 [[I]], 1
+; CHECK-PROFIT-INSTORDER-NEXT:    [[EC_I:%.*]] = icmp eq i64 [[I_INC]], 100
+; CHECK-PROFIT-INSTORDER-NEXT:    br i1 [[EC_I]], label %[[EXIT:.*]], label %[[LOOP_I_HEADER]]
+; CHECK-PROFIT-INSTORDER:       [[EXIT]]:
+; CHECK-PROFIT-INSTORDER-NEXT:    ret void
+;
+; CHECK-PROFIT-IGNORE-LABEL: define void @all_eq(
+; CHECK-PROFIT-IGNORE-SAME: ptr [[A:%.*]]) {
+; CHECK-PROFIT-IGNORE-NEXT:  [[ENTRY:.*:]]
+; CHECK-PROFIT-IGNORE-NEXT:    br label %[[LOOP_J_PREHEADER:.*]]
+; CHECK-PROFIT-IGNORE:       [[LOOP_I_HEADER_PREHEADER:.*]]:
+; CHECK-PROFIT-IGNORE-NEXT:    br label %[[LOOP_I_HEADER:.*]]
+; CHECK-PROFIT-IGNORE:       [[LOOP_I_HEADER]]:
+; CHECK-PROFIT-IGNORE-NEXT:    [[I:%.*]] = phi i64 [ [[I_INC:%.*]], %[[LOOP_I_LATCH:.*]] ], [ 0, %[[LOOP_I_HEADER_PREHEADER]] ]
+; CHECK-PROFIT-IGNORE-NEXT:    br label %[[LOOP_J_SPLIT1:.*]]
+; CHECK-PROFIT-IGNORE:       [[LOOP_J_PREHEADER]]:
+; CHECK-PROFIT-IGNORE-NEXT:    br label %[[LOOP_J:.*]]
+; CHECK-PROFIT-IGNORE:       [[LOOP_J]]:
+; CHECK-PROFIT-IGNORE-NEXT:    [[J:%.*]] = phi i64 [ [[TMP0:%.*]], %[[LOOP_J_SPLIT:.*]] ], [ 0, %[[LOOP_J_PREHEADER]] ]
+; CHECK-PROFIT-IGNORE-NEXT:    br label %[[LOOP_I_HEADER_PREHEADER]]
+; CHECK-PROFIT-IGNORE:       [[LOOP_J_SPLIT1]]:
+; CHECK-PROFIT-IGNORE-NEXT:    [[GEP:%.*]] = getelementptr i8, ptr [[A]], i64 [[J]]
+; CHECK-PROFIT-IGNORE-NEXT:    store i8 0, ptr [[GEP]], align 1
+; CHECK-PROFIT-IGNORE-NEXT:    [[J_INC:%.*]] = add i64 [[J]], 1
+; CHECK-PROFIT-IGNORE-NEXT:    [[EC_J:%.*]] = icmp eq i64 [[J_INC]], 100
+; CHECK-PROFIT-IGNORE-NEXT:    br label %[[LOOP_I_LATCH]]
+; CHECK-PROFIT-IGNORE:       [[LOOP_J_SPLIT]]:
+; CHECK-PROFIT-IGNORE-NEXT:    [[TMP0]] = add i64 [[J]], 1
+; CHECK-PROFIT-IGNORE-NEXT:    [[TMP1:%.*]] = icmp eq i64 [[TMP0]], 100
+; CHECK-PROFIT-IGNORE-NEXT:    br i1 [[TMP1]], label %[[EXIT:.*]], label %[[LOOP_J]]
+; CHECK-PROFIT-IGNORE:       [[LOOP_I_LATCH]]:
+; CHECK-PROFIT-IGNORE-NEXT:    [[I_INC]] = add i64 [[I]], 1
+; CHECK-PROFIT-IGNORE-NEXT:    [[EC_I:%.*]] = icmp eq i64 [[I_INC]], 100
+; CHECK-PROFIT-IGNORE-NEXT:    br i1 [[EC_I]], label %[[LOOP_J_SPLIT]], label %[[LOOP_I_HEADER]]
+; CHECK-PROFIT-IGNORE:       [[EXIT]]:
+; CHECK-PROFIT-IGNORE-NEXT:    ret void
 ;
 entry:
   br label %loop.i.header
@@ -68,26 +99,57 @@ exit:
 ;
 
 define void @eq_all(ptr %A) {
-; CHECK-LABEL: define void @eq_all(
-; CHECK-SAME: ptr [[A:%.*]]) {
-; CHECK-NEXT:  [[ENTRY:.*]]:
-; CHECK-NEXT:    br label %[[LOOP_I_HEADER:.*]]
-; CHECK:       [[LOOP_I_HEADER]]:
-; CHECK-NEXT:    [[I:%.*]] = phi i64 [ 0, %[[ENTRY]] ], [ [[I_INC:%.*]], %[[LOOP_I_LATCH:.*]] ]
-; CHECK-NEXT:    br label %[[LOOP_J:.*]]
-; CHECK:       [[LOOP_J]]:
-; CHECK-NEXT:    [[J:%.*]] = phi i64 [ 0, %[[LOOP_I_HEADER]] ], [ [[J_INC:%.*]], %[[LOOP_J]] ]
-; CHECK-NEXT:    [[GEP:%.*]] = getelementptr i8, ptr [[A]], i64 [[I]]
-; CHECK-NEXT:    store i8 0, ptr [[GEP]], align 1
-; CHECK-NEXT:    [[J_INC]] = add i64 [[J]], 1
-; CHECK-NEXT:    [[EC_J:%.*]] = icmp eq i64 [[J_INC]], 100
-; CHECK-NEXT:    br i1 [[EC_J]], label %[[LOOP_I_LATCH]], label %[[LOOP_J]]
-; CHECK:       [[LOOP_I_LATCH]]:
-; CHECK-NEXT:    [[I_INC]] = add i64 [[I]], 1
-; CHECK-NEXT:    [[EC_I:%.*]] = icmp eq i64 [[I_INC]], 100
-; CHECK-NEXT:    br i1 [[EC_I]], label %[[EXIT:.*]], label %[[LOOP_I_HEADER]]
-; CHECK:       [[EXIT]]:
-; CHECK-NEXT:    ret void
+; CHECK-PROFIT-INSTORDER-LABEL: define void @eq_all(
+; CHECK-PROFIT-INSTORDER-SAME: ptr [[A:%.*]]) {
+; CHECK-PROFIT-INSTORDER-NEXT:  [[ENTRY:.*]]:
+; CHECK-PROFIT-INSTORDER-NEXT:    br label %[[LOOP_I_HEADER:.*]]
+; CHECK-PROFIT-INSTORDER:       [[LOOP_I_HEADER]]:
+; CHECK-PROFIT-INSTORDER-NEXT:    [[I:%.*]] = phi i64 [ 0, %[[ENTRY]] ], [ [[I_INC:%.*]], %[[LOOP_I_LATCH:.*]] ]
+; CHECK-PROFIT-INSTORDER-NEXT:    br label %[[LOOP_J:.*]]
+; CHECK-PROFIT-INSTORDER:       [[LOOP_J]]:
+; CHECK-PROFIT-INSTORDER-NEXT:    [[J:%.*]] = phi i64 [ 0, %[[LOOP_I_HEADER]] ], [ [[J_INC:%.*]], %[[LOOP_J]] ]
+; CHECK-PROFIT-INSTORDER-NEXT:    [[GEP:%.*]] = getelementptr i8, ptr [[A]], i64 [[I]]
+; CHECK-PROFIT-INSTORDER-NEXT:    store i8 0, ptr [[GEP]], align 1
+; CHECK-PROFIT-INSTORDER-NEXT:    [[J_INC]] = add i64 [[J]], 1
+; CHECK-PROFIT-INSTORDER-NEXT:    [[EC_J:%.*]] = icmp eq i64 [[J_INC]], 100
+; CHECK-PROFIT-INSTORDER-NEXT:    br i1 [[EC_J]], label %[[LOOP_I_LATCH]], label %[[LOOP_J]]
+; CHECK-PROFIT-INSTORDER:       [[LOOP_I_LATCH]]:
+; CHECK-PROFIT-INSTORDER-NEXT:    [[I_INC]] = add i64 [[I]], 1
+; CHECK-PROFIT-INSTORDER-NEXT:    [[EC_I:%.*]] = icmp eq i64 [[I_INC]], 100
+; CHECK-PROFIT-INSTORDER-NEXT:    br i1 [[EC_I]], label %[[EXIT:.*]], label %[[LOOP_I_HEADER]]
+; CHECK-PROFIT-INSTORDER:       [[EXIT]]:
+; CHECK-PROFIT-INSTORDER-NEXT:    ret void
+;
+; CHECK-PROFIT-IGNORE-LABEL: define void @eq_all(
+; CHECK-PROFIT-IGNORE-SAME: ptr [[A:%.*]]) {
+; CHECK-PROFIT-IGNORE-NEXT:  [[ENTRY:.*:]]
+; CHECK-PROFIT-IGNORE-NEXT:    br label %[[LOOP_J_PREHEADER:.*]]
+; CHECK-PROFIT-IGNORE:       [[LOOP_I_HEADER_PREHEADER:.*]]:
+; CHECK-PROFIT-IGNORE-NEXT:    br label %[[LOOP_I_HEADER:.*]]
+; CHECK-PROFIT-IGNORE:       [[LOOP_I_HEADER]]:
+; CHECK-PROFIT-IGNORE-NEXT:    [[I:%.*]] = phi i64 [ [[I_INC:%.*]], %[[LOOP_I_LATCH:.*]] ], [ 0, %[[LOOP_I_HEADER_PREHEADER]] ]
+; CHECK-PROFIT-IGNORE-NEXT:    br label %[[LOOP_J_SPLIT1:.*]]
+; CHECK-PROFIT-IGNORE:       [[LOOP_J_PREHEADER]]:
+; CHECK-PROFIT-IGNORE-NEXT:    br label %[[LOOP_J:.*]]
+; CHECK-PROFIT-IGNORE:       [[LOOP_J]]:
+; CHECK-PROFIT-IGNORE-NEXT:    [[J:%.*]] = phi i64 [ [[TMP0:%.*]], %[[LOOP_J_SPLIT:.*]] ], [ 0, %[[LOOP_J_PREHEADER]] ]
+; CHECK-PROFIT-IGNORE-NEXT:    br label %[[LOOP_I_HEADER_PREHEADER]]
+; CHECK-PROFIT-IGNORE:       [[LOOP_J_SPLIT1]]:
+; CHECK-PROFIT-IGNORE-NEXT:    [[GEP:%.*]] = getelementptr i8, ptr [[A]], i64 [[I]]
+; CHECK-PROFIT-IGNORE-NEXT:    store i8 0, ptr [[GEP]], align 1
+; CHECK-PROFIT-IGNORE-NEXT:    [[J_INC:%.*]] = add i64 [[J]], 1
+; CHECK-PROFIT-IGNORE-NEXT:    [[EC_J:%.*]] = icmp eq i64 [[J_INC]], 100
+; CHECK-PROFIT-IGNORE-NEXT:    br label %[[LOOP_I_LATCH]]
+; CHECK-PROFIT-IGNORE:       [[LOOP_J_SPLIT]]:
+; CHECK-PROFIT-IGNORE-NEXT:    [[TMP0]] = add i64 [[J]], 1
+; CHECK-PROFIT-IGNORE-NEXT:    [[TMP1:%.*]] = icmp eq i64 [[TMP0]], 100
+; CHECK-PROFIT-IGNORE-NEXT:    br i1 [[TMP1]], label %[[EXIT:.*]], label %[[LOOP_J]]
+; CHECK-PROFIT-IGNORE:       [[LOOP_I_LATCH]]:
+; CHECK-PROFIT-IGNORE-NEXT:    [[I_INC]] = add i64 [[I]], 1
+; CHECK-PROFIT-IGNORE-NEXT:    [[EC_I:%.*]] = icmp eq i64 [[I_INC]], 100
+; CHECK-PROFIT-IGNORE-NEXT:    br i1 [[EC_I]], label %[[LOOP_J_SPLIT]], label %[[LOOP_I_HEADER]]
+; CHECK-PROFIT-IGNORE:       [[EXIT]]:
+; CHECK-PROFIT-IGNORE-NEXT:    ret void
 ;
 entry:
   br label %loop.i.header
@@ -113,5 +175,4 @@ exit:
   ret void
 }
 ;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
-; CHECK-PROFIT-IGNORE: {{.*}}
-; CHECK-PROFIT-INSTORDER: {{.*}}
+; CHECK: {{.*}}
diff --git a/llvm/test/Transforms/LoopInterchange/inner-only-reductions.ll b/llvm/test/Transforms/LoopInterchange/inner-only-reductions.ll
index c6c2e2a8a5187..090491d36146a 100644
--- a/llvm/test/Transforms/LoopInterchange/inner-only-reductions.ll
+++ b/llvm/test/Transforms/LoopInterchange/inner-only-reductions.ll
@@ -2,11 +2,9 @@
 ; RUN:     -verify-dom-info -verify-loop-info -verify-loop-lcssa 2>&1 | FileCheck -check-prefix=IR %s
 ; RUN: FileCheck --input-file=%t %s
 
-; Both tests should be rejected as interchange candidates. For now, they are
-; rejected for dependence analysis reasons, but that's because support for 'S'
-; scalar dependencies was removed. When that is properly, the inner loop only
-; reductions should still not be supported currently, see discussion at D53027
-; for more information on the required checks.
+; Both tests should be rejected as interchange candidates. The inner loop only
+; reductions are not be supported currently, see discussion at D53027 for more
+; information on the required checks.
 
 @A = common global [500 x [500 x i32]] zeroinitializer
 @X = common global i32 0
@@ -21,7 +19,7 @@
 
 ; CHECK: --- !Missed
 ; CHECK-NEXT: Pass:            loop-interchange
-; CHECK-NEXT: Name:            Dependence
+; CHECK-NEXT: Name:            UnsupportedPHIInner
 ; CHECK-NEXT: Function:        reduction_01
 
 ; IR-LABEL: @reduction_01(
diff --git a/llvm/test/Transforms/LoopInterchange/innermost-latch-uses-values-in-middle-header.ll b/llvm/test/Transforms/LoopInterchange/innermost-latch-uses-values-in-middle-header.ll
index da37395372e5f..230f7dc2bcfad 100644
--- a/llvm/test/Transforms/LoopInterchange/innermost-latch-uses-values-in-middle-header.ll
+++ b/llvm/test/Transforms/LoopInterchange/innermost-latch-uses-values-in-middle-header.ll
@@ -1,11 +1,3 @@
-; Remove 'S' Scalar Dependencies #119345
-; Scalar dependencies are not handled correctly, so they were removed to avoid
-; miscompiles. The loop nest in this test case used to be interchanged, but it's
-; no longer triggering. XFAIL'ing this test to indicate that this test should
-; interchanged if scalar deps are handled correctly.
-;
-; XFAIL: *
-
 ; RUN: opt < %s -passes=loop-interchange -verify-dom-info -verify-loop-info -pass-remarks-output=%t -disable-output
 ; RUN: FileCheck -input-file %t %s
 
diff --git a/llvm/test/Transforms/LoopInterchange/large-nested-6d.ll b/llvm/test/Transforms/LoopInterchange/large-nested-6d.ll
index 590c21fd5a1be..e00a2bc36afe5 100644
--- a/llvm/test/Transforms/LoopInterchange/large-nested-6d.ll
+++ b/llvm/test/Transforms/LoopInterchange/large-nested-6d.ll
@@ -75,10 +75,10 @@ target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i6
 ; CHECK-NEXT:  ...
 ; CHECK-NEXT:  --- !Missed
 ; CHECK-NEXT:  Pass:            loop-interchange
-; CHECK-NEXT:  Name:            Dependence
-; CHECK-NEXT:  Function:        test
-; CHECK-NEXT:  Args:
-; CHECK-NEXT:    - String:          Cannot interchange loops due to dependences.
+; CHECK-NEXT: Name:            NotTightlyNested
+; CHECK-NEXT: Function:        test
+; CHECK-NEXT: Args:
+; CHECK-NEXT:   - String:          Cannot interchange loops because they are not tightly nested.
 ; CHECK-NEXT:  ...
 ; CHECK-NEXT:  --- !Missed
 ; CHECK-NEXT:  Pass:            loop-interchange
diff --git a/llvm/test/Transforms/LoopInterchange/legality-check.ll b/llvm/test/Transforms/LoopInterchange/legality-check.ll
index 462941309cf7f..e372ea7c6fd48 100644
--- a/llvm/test/Transforms/LoopInterchange/legality-check.ll
+++ b/llvm/test/Transforms/LoopInterchange/legality-check.ll
@@ -149,7 +149,8 @@ exit:
 ;;      for (int k = 0; k < 19; k++)
 ;;        b[i][j][k] = b[i][5][k + 1];
 ;;
-;; The direction vector of `b` is [= * *]. We cannot interchange all the loops.
+;; The direction vector of `b` is [= * *]. We can interchange the i-loop and
+;; the j-loop.
 
 ; CHECK:      Dependency matrix before interchange:
 ; CHECK-NEXT: = * *
@@ -157,8 +158,10 @@ exit:
 ; CHECK-NEXT: Failed interchange InnerLoopId = 2 and OuterLoopId = 1 due to dependence
 ; CHECK-NEXT: Cannot prove legality, not interchanging loops 'for.j.header' and 'for.k'
 ; CHECK-NEXT: Processing InnerLoopId = 1 and OuterLoopId = 0
-; CHECK-NEXT: Failed interchange InnerLoopId = 1 and OuterLoopId = 0 due to dependence
-; CHECK-NEXT: Cannot prove legality, not interchanging loops 'for.i.header' and 'for.j.header'
+; CHECK-NEXT: Checking if loops 'for.i.header' and 'for.j.header' are tightly nested
+; CHECK-NEXT: Checking instructions in Loop header and Loop latch
+; CHECK-NEXT: Loops are perfectly nested
+; CHECK-NEXT: Loops 'for.i.header' and 'for.j.header' are legal to interchange
 
 define void @eq_all_lt() {
 entry:
diff --git a/llvm/test/Transforms/LoopInterchange/pr43176-move-to-new-latch.ll b/llvm/test/Transforms/LoopInterchange/pr43176-move-to-new-latch.ll
index 69ef1e8ff7b95..71cf8f65770d6 100644
--- a/llvm/test/Transforms/LoopInterchange/pr43176-move-to-new-latch.ll
+++ b/llvm/test/Transforms/LoopInterchange/pr43176-move-to-new-latch.ll
@@ -1,9 +1,10 @@
-; RUN: opt < %s -passes=loop-interchange -cache-line-size=64 -pass-remarks-missed='loop-interchange' -pass-remarks-output=%t -S
+; RUN: opt < %s -passes=loop-interchange -loop-interchange-profitabilities=instorder -pass-remarks-missed='loop-interchange' -pass-remarks-output=%t -S
 ; RUN: FileCheck --input-file=%t %s
 
 @b = external dso_local global [5 x i32], align 16
 
-;; Not profitable to interchange, because the access is invariant to j loop.
+;; Not profitable to interchange in terms of locality of reference, because the
+;; access is invariant to j loop.
 ;;
 ;;  for(int i=0;i<4;i++) {
 ;;    for(int j=1;j<4;j++) {
@@ -13,10 +14,11 @@
 
 ; CHECK: --- !Missed
 ; CHECK-NEXT: Pass:            loop-interchange
-; CHECK-NEXT: Name:            Dependence
+; CHECK-NEXT: Name:            InterchangeNotProfitable
 ; CHECK-NEXT: Function:        test1
 ; CHECK-NEXT: Args:
-; CHECK-NEXT:  - String:       Cannot interchange loops due to dependences.
+; CHECK-NEXT:   - String:          Insufficient information to calculate the cost of loop for interchange.
+
 
 define void @test1() {
 entry:
@@ -54,10 +56,10 @@ exit:
 
 ; CHECK: --- !Missed
 ; CHECK-NEXT: Pass:            loop-interchange
-; CHECK-NEXT: Name:            Dependence
+; CHECK-NEXT: Name:            InterchangeNotProfitable
 ; CHECK-NEXT: Function:        test2
 ; CHECK-NEXT: Args:
-; CHECK-NEXT:  - String:       Cannot interchange loops due to dependences.
+; CHECK-NEXT:   - String:          Insufficient information to calculate the cost of loop for interchange.
 
 define void @test2() {
 entry:



More information about the llvm-branch-commits mailing list