llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang-driver Author: Sjoerd Meijer (sjoerdmeijer) <details> <summary>Changes</summary> This introduces options `-floop-interchange` and `-fno-loop-interchange` to enable/disable the loop-interchange pass. This is part of the work that tries to get that pass enabled by default (#<!-- -->124911), where it was remarked that a user facing option to control this would be convenient to have. The option name is the same as GCC's. --- Full diff: https://github.com/llvm/llvm-project/pull/125830.diff 3 Files Affected: - (modified) clang/include/clang/Driver/Options.td (+3) - (modified) clang/lib/Driver/ToolChains/Clang.cpp (+10) - (modified) clang/test/Driver/clang_f_opts.c (+7) ``````````diff diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index df705104d9ea31..3132f8946c6d3b 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -4073,6 +4073,9 @@ defm assumptions : BoolFOption<"assumptions", "Disable codegen and compile-time checks for C++23's [[assume]] attribute">, PosFlag<SetTrue>>; +def floop_interchange : Flag<["-"], "floop-interchange">, Group<f_Group>, + HelpText<"Enable the loop interchange pass">; +def fno_loop_interchange: Flag<["-"], "fno-loop-interchange">, Group<f_Group>; def fvectorize : Flag<["-"], "fvectorize">, Group<f_Group>, HelpText<"Enable the loop vectorization passes">; def fno_vectorize : Flag<["-"], "fno-vectorize">, Group<f_Group>; diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 33f08cf28feca1..757093c3d3a5cf 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -7619,6 +7619,16 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, Args.addOptOutFlag(CmdArgs, options::OPT_fgnu_inline_asm, options::OPT_fno_gnu_inline_asm); + // Handle -floop-interchange + if (Arg *A = Args.getLastArg(options::OPT_floop_interchange, + options::OPT_fno_loop_interchange)) { + CmdArgs.push_back("-mllvm"); + if (A->getOption().matches(options::OPT_floop_interchange)) + CmdArgs.push_back("-enable-loopinterchange=true"); + else + CmdArgs.push_back("-enable-loopinterchange=false"); + } + // Enable vectorization per default according to the optimization level // selected. For optimization levels that want vectorization we use the alias // option to simplify the hasFlag logic. diff --git a/clang/test/Driver/clang_f_opts.c b/clang/test/Driver/clang_f_opts.c index 38f25898c95568..908d592928b01f 100644 --- a/clang/test/Driver/clang_f_opts.c +++ b/clang/test/Driver/clang_f_opts.c @@ -156,6 +156,13 @@ // CHECK-VECTORIZE: "-vectorize-loops" // CHECK-NO-VECTORIZE-NOT: "-vectorize-loops" +// RUN: %clang -### -S -floop-interchange %s 2>&1 | FileCheck -check-prefix=CHECK-INTERCHANGE %s +// RUN: %clang -### -S -fno-loop-interchange -floop-interchange %s 2>&1 | FileCheck -check-prefix=CHECK-INTERCHANGE %s +// RUN: %clang -### -S -fno-loop-interchange %s 2>&1 | FileCheck -check-prefix=CHECK-NO-INTERCHANGE %s +// RUN: %clang -### -S -floop-interchange -fno-loop-interchange %s 2>&1 | FileCheck -check-prefix=CHECK-NO-INTERCHANGE %s +// CHECK-INTERCHANGE: "-mllvm" "-enable-loopinterchange=true" +// CHECK-NO-INTERCHANGE: "-mllvm" "-enable-loopinterchange=false" + // RUN: %clang -### -S -fslp-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-SLP-VECTORIZE %s // RUN: %clang -### -S -fno-slp-vectorize -fslp-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-SLP-VECTORIZE %s // RUN: %clang -### -S -fno-slp-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-NO-SLP-VECTORIZE %s `````````` </details> https://github.com/llvm/llvm-project/pull/125830 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits