Index: llvm/lib/Transforms/Scalar/LoopInterchange.cpp =================================================================== --- llvm/lib/Transforms/Scalar/LoopInterchange.cpp +++ llvm/lib/Transforms/Scalar/LoopInterchange.cpp @@ -1117,10 +1117,10 @@ // If the inner loop is loop independent or doesn't carry any dependency it is // profitable to move this to outer position. for (auto &Row : DepMatrix) { - if (Row[InnerLoopId] != 'S' && Row[InnerLoopId] != 'I') + if (Row[InnerLoopId] != 'I' && Row[InnerLoopId] != '=') return false; // TODO: We need to improve this heuristic. - if (Row[OuterLoopId] != '=') + if (Row[OuterLoopId] == '=') return false; } // If outer loop has dependence and inner loop is loop independent then it is Index: llvm/test/Transforms/LoopInterchange/pr43797-lcssa-for-multiple-outer-loop-blocks.ll =================================================================== --- llvm/test/Transforms/LoopInterchange/pr43797-lcssa-for-multiple-outer-loop-blocks.ll +++ llvm/test/Transforms/LoopInterchange/pr43797-lcssa-for-multiple-outer-loop-blocks.ll @@ -1,5 +1,5 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py -; RUN: opt -loop-interchange -cache-line-size=64 -verify-loop-lcssa -S %s | FileCheck %s +; RUN: opt -loop-interchange -cache-line-size=64 -loop-interchange-threshold=-1000 -verify-loop-lcssa -S %s | FileCheck %s ; Tests for PR43797.