[flang] Disable loop interchange by default (#155279)

Disable loop interchange by default, while keeping the ability to
explicitly enable using `-floop-interchange`. This matches Clang.

See discussion on https://github.com/llvm/llvm-project/pull/140182.
This commit is contained in:
Nikita Popov
2025-08-26 09:14:21 +02:00
committed by GitHub
parent 83583b211e
commit 8849750e99
2 changed files with 5 additions and 11 deletions

View File

@@ -3331,14 +3331,8 @@ void tools::handleVectorizeSLPArgs(const ArgList &Args,
void tools::handleInterchangeLoopsArgs(const ArgList &Args,
ArgStringList &CmdArgs) {
// FIXME: instead of relying on shouldEnableVectorizerAtOLevel, we may want to
// implement a separate function to infer loop interchange from opt level.
// For now, enable loop-interchange at the same opt levels as loop-vectorize.
bool EnableInterchange = shouldEnableVectorizerAtOLevel(Args, false);
OptSpecifier InterchangeAliasOption =
EnableInterchange ? options::OPT_O_Group : options::OPT_floop_interchange;
if (Args.hasFlag(options::OPT_floop_interchange, InterchangeAliasOption,
options::OPT_fno_loop_interchange, EnableInterchange))
if (Args.hasFlag(options::OPT_floop_interchange,
options::OPT_fno_loop_interchange, false))
CmdArgs.push_back("-floop-interchange");
}

View File

@@ -2,9 +2,9 @@
! RUN: %flang -### -S -fno-loop-interchange %s 2>&1 | FileCheck -check-prefix=CHECK-NO-LOOP-INTERCHANGE %s
! RUN: %flang -### -S -O0 %s 2>&1 | FileCheck -check-prefix=CHECK-NO-LOOP-INTERCHANGE %s
! RUN: %flang -### -S -O1 %s 2>&1 | FileCheck -check-prefix=CHECK-NO-LOOP-INTERCHANGE %s
! RUN: %flang -### -S -O2 %s 2>&1 | FileCheck -check-prefix=CHECK-LOOP-INTERCHANGE %s
! RUN: %flang -### -S -O3 %s 2>&1 | FileCheck -check-prefix=CHECK-LOOP-INTERCHANGE %s
! RUN: %flang -### -S -Os %s 2>&1 | FileCheck -check-prefix=CHECK-LOOP-INTERCHANGE %s
! RUN: %flang -### -S -O2 %s 2>&1 | FileCheck -check-prefix=CHECK-NO-LOOP-INTERCHANGE %s
! RUN: %flang -### -S -O3 %s 2>&1 | FileCheck -check-prefix=CHECK-NO-LOOP-INTERCHANGE %s
! RUN: %flang -### -S -Os %s 2>&1 | FileCheck -check-prefix=CHECK-NO-LOOP-INTERCHANGE %s
! RUN: %flang -### -S -Oz %s 2>&1 | FileCheck -check-prefix=CHECK-NO-LOOP-INTERCHANGE %s
! CHECK-LOOP-INTERCHANGE: "-floop-interchange"
! CHECK-NO-LOOP-INTERCHANGE-NOT: "-floop-interchange"