[PATCH] D141307: Add -f[no-]loop-versioning option
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rGefae695d52cc: Add -f[no-]loop-versioning option (authored by MatsPetersson). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D141307/new/ https://reviews.llvm.org/D141307 Files: clang/include/clang/Driver/Options.td clang/lib/Driver/ToolChains/Flang.cpp clang/lib/Driver/ToolChains/Flang.h flang/include/flang/Frontend/CodeGenOptions.def flang/include/flang/Tools/CLOptions.inc flang/lib/Frontend/CompilerInvocation.cpp flang/lib/Frontend/FrontendActions.cpp flang/test/Driver/driver-help-hidden.f90 flang/test/Driver/driver-help.f90 flang/test/Driver/frontend-forwarding.f90 flang/test/Driver/version-loops.f90 Index: flang/test/Driver/version-loops.f90 === --- /dev/null +++ flang/test/Driver/version-loops.f90 @@ -0,0 +1,54 @@ +! Test that flang-new forwards the -f{no-,}version-loops-for-stride +! options correctly to flang-new -fc1 for different variants of optimisation +! and explicit flags. + +! RUN: %flang -### %s -o %t 2>&1 -O3 \ +! RUN: | FileCheck %s + +! RUN: %flang -### %s -o %t 2>&1 -O2 \ +! RUN: | FileCheck %s --check-prefix=CHECK-O2 + +! RUN: %flang -### %s -o %t 2>&1 -O2 -fversion-loops-for-stride \ +! RUN: | FileCheck %s --check-prefix=CHECK-O2-with + +! RUN: %flang -### %s -o %t 2>&1 -O4 \ +! RUN: | FileCheck %s --check-prefix=CHECK-O4 + +! RUN: %flang -### %s -o %t 2>&1 -Ofast \ +! RUN: | FileCheck %s --check-prefix=CHECK-Ofast + +! RUN: %flang -### %s -o %t 2>&1 -Ofast -fno-version-loops-for-stride \ +! RUN: | FileCheck %s --check-prefix=CHECK-Ofast-no + +! RUN: %flang -### %s -o %t 2>&1 -O3 -fno-version-loops-for-stride \ +! RUN: | FileCheck %s --check-prefix=CHECK-O3-no + +! CHECK: "{{.*}}flang-new" "-fc1" +! CHECK-SAME: "-fversion-loops-for-stride" +! CHECK-SAME: "-O3" + +! CHECK-O2: "{{.*}}flang-new" "-fc1" +! CHECK-O2-NOT: "-fversion-loops-for-stride" +! CHECK-O2-SAME: "-O2" + +! CHECK-O2-with: "{{.*}}flang-new" "-fc1" +! CHECK-O2-with-SAME: "-fversion-loops-for-stride" +! CHECK-O2-with-SAME: "-O2" + +! CHECK-O4: "{{.*}}flang-new" "-fc1" +! CHECK-O4-SAME: "-fversion-loops-for-stride" +! CHECK-O4-SAME: "-O3" + +! CHECK-Ofast: "{{.*}}flang-new" "-fc1" +! CHECK-Ofast-SAME: "-ffast-math" +! CHECK-Ofast-SAME: "-fversion-loops-for-stride" +! CHECK-Ofast-SAME: "-O3" + +! CHECK-Ofast-no: "{{.*}}flang-new" "-fc1" +! CHECK-Ofast-no-SAME: "-ffast-math" +! CHECK-Ofast-no-NOT: "-fversion-loops-for-stride" +! CHECK-Ofast-no-SAME: "-O3" + +! CHECK-O3-no: "{{.*}}flang-new" "-fc1" +! CHECK-O3-no-NOT: "-fversion-loops-for-stride" +! CHECK-O3-no-SAME: "-O3" Index: flang/test/Driver/frontend-forwarding.f90 === --- flang/test/Driver/frontend-forwarding.f90 +++ flang/test/Driver/frontend-forwarding.f90 @@ -15,6 +15,8 @@ ! RUN: -fassociative-math \ ! RUN: -freciprocal-math \ ! RUN: -fpass-plugin=Bye%pluginext \ +! RUN: -fversion-loops-for-stride \ +! RUN: -mllvm -print-before-all\ ! RUN: -mllvm -print-before-all \ ! RUN: -save-temps=obj \ ! RUN: -P \ @@ -34,5 +36,6 @@ ! CHECK: "-freciprocal-math" ! CHECK: "-fconvert=little-endian" ! CHECK: "-fpass-plugin=Bye +! CHECK: "-fversion-loops-for-stride" ! CHECK: "-mllvm" "-print-before-all" ! CHECK: "-save-temps=obj" Index: flang/test/Driver/driver-help.f90 === --- flang/test/Driver/driver-help.f90 +++ flang/test/Driver/driver-help.f90 @@ -48,6 +48,8 @@ ! HELP-NEXT: -fno-integrated-as Disable the integrated assembler ! HELP-NEXT: -fno-signed-zeros Allow optimizations that ignore the sign of floating point zeros ! HELP-NEXT: -fno-stack-arrays Allocate array temporaries on the heap (default) +! HELP-NEXT: -fno-version-loops-for-stride +! HELP-NEXT:Do not create unit-strided loops (default) ! HELP-NEXT: -fopenacc Enable OpenACC ! HELP-NEXT: -fopenmp Parse OpenMP pragmas and generate parallel code. ! HELP-NEXT: -fpass-plugin= Load pass plugin from a dynamic shared object file (only with new pass manager). @@ -55,6 +57,8 @@ ! HELP-NEXT: -fstack-arrays Attempt to allocate array temporaries on the stack, no matter their size ! HELP-NEXT: -fsyntax-only Run the preprocessor, parser and semantic analysis stages ! HELP-NEXT: -funderscoring Appends one trailing underscore to external names +! HELP-NEXT: -fversion-loops-for-stride +! HELP-NEXT:Create unit-strided versions of loops ! HELP-NEXT: -fxor-operator Enable .XOR. as a synonym of .NEQV. ! HELP-NEXT: -gline-tables-only Emit debug line number tables only ! HELP-NEXT: -g Generate
[PATCH] D141307: Add -f[no-]loop-versioning option
Leporacanthicus updated this revision to Diff 514525. Leporacanthicus added a comment. Rebase only Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D141307/new/ https://reviews.llvm.org/D141307 Files: clang/include/clang/Driver/Options.td clang/lib/Driver/ToolChains/Flang.cpp clang/lib/Driver/ToolChains/Flang.h flang/include/flang/Frontend/CodeGenOptions.def flang/include/flang/Tools/CLOptions.inc flang/lib/Frontend/CompilerInvocation.cpp flang/lib/Frontend/FrontendActions.cpp flang/test/Driver/driver-help-hidden.f90 flang/test/Driver/driver-help.f90 flang/test/Driver/frontend-forwarding.f90 flang/test/Driver/version-loops.f90 Index: flang/test/Driver/version-loops.f90 === --- /dev/null +++ flang/test/Driver/version-loops.f90 @@ -0,0 +1,54 @@ +! Test that flang-new forwards the -f{no-,}version-loops-for-stride +! options correctly to flang-new -fc1 for different variants of optimisation +! and explicit flags. + +! RUN: %flang -### %s -o %t 2>&1 -O3 \ +! RUN: | FileCheck %s + +! RUN: %flang -### %s -o %t 2>&1 -O2 \ +! RUN: | FileCheck %s --check-prefix=CHECK-O2 + +! RUN: %flang -### %s -o %t 2>&1 -O2 -fversion-loops-for-stride \ +! RUN: | FileCheck %s --check-prefix=CHECK-O2-with + +! RUN: %flang -### %s -o %t 2>&1 -O4 \ +! RUN: | FileCheck %s --check-prefix=CHECK-O4 + +! RUN: %flang -### %s -o %t 2>&1 -Ofast \ +! RUN: | FileCheck %s --check-prefix=CHECK-Ofast + +! RUN: %flang -### %s -o %t 2>&1 -Ofast -fno-version-loops-for-stride \ +! RUN: | FileCheck %s --check-prefix=CHECK-Ofast-no + +! RUN: %flang -### %s -o %t 2>&1 -O3 -fno-version-loops-for-stride \ +! RUN: | FileCheck %s --check-prefix=CHECK-O3-no + +! CHECK: "{{.*}}flang-new" "-fc1" +! CHECK-SAME: "-fversion-loops-for-stride" +! CHECK-SAME: "-O3" + +! CHECK-O2: "{{.*}}flang-new" "-fc1" +! CHECK-O2-NOT: "-fversion-loops-for-stride" +! CHECK-O2-SAME: "-O2" + +! CHECK-O2-with: "{{.*}}flang-new" "-fc1" +! CHECK-O2-with-SAME: "-fversion-loops-for-stride" +! CHECK-O2-with-SAME: "-O2" + +! CHECK-O4: "{{.*}}flang-new" "-fc1" +! CHECK-O4-SAME: "-fversion-loops-for-stride" +! CHECK-O4-SAME: "-O3" + +! CHECK-Ofast: "{{.*}}flang-new" "-fc1" +! CHECK-Ofast-SAME: "-ffast-math" +! CHECK-Ofast-SAME: "-fversion-loops-for-stride" +! CHECK-Ofast-SAME: "-O3" + +! CHECK-Ofast-no: "{{.*}}flang-new" "-fc1" +! CHECK-Ofast-no-SAME: "-ffast-math" +! CHECK-Ofast-no-NOT: "-fversion-loops-for-stride" +! CHECK-Ofast-no-SAME: "-O3" + +! CHECK-O3-no: "{{.*}}flang-new" "-fc1" +! CHECK-O3-no-NOT: "-fversion-loops-for-stride" +! CHECK-O3-no-SAME: "-O3" Index: flang/test/Driver/frontend-forwarding.f90 === --- flang/test/Driver/frontend-forwarding.f90 +++ flang/test/Driver/frontend-forwarding.f90 @@ -15,6 +15,8 @@ ! RUN: -fassociative-math \ ! RUN: -freciprocal-math \ ! RUN: -fpass-plugin=Bye%pluginext \ +! RUN: -fversion-loops-for-stride \ +! RUN: -mllvm -print-before-all\ ! RUN: -mllvm -print-before-all \ ! RUN: -save-temps=obj \ ! RUN: -P \ @@ -34,5 +36,6 @@ ! CHECK: "-freciprocal-math" ! CHECK: "-fconvert=little-endian" ! CHECK: "-fpass-plugin=Bye +! CHECK: "-fversion-loops-for-stride" ! CHECK: "-mllvm" "-print-before-all" ! CHECK: "-save-temps=obj" Index: flang/test/Driver/driver-help.f90 === --- flang/test/Driver/driver-help.f90 +++ flang/test/Driver/driver-help.f90 @@ -48,6 +48,8 @@ ! HELP-NEXT: -fno-integrated-as Disable the integrated assembler ! HELP-NEXT: -fno-signed-zeros Allow optimizations that ignore the sign of floating point zeros ! HELP-NEXT: -fno-stack-arrays Allocate array temporaries on the heap (default) +! HELP-NEXT: -fno-version-loops-for-stride +! HELP-NEXT:Do not create unit-strided loops (default) ! HELP-NEXT: -fopenacc Enable OpenACC ! HELP-NEXT: -fopenmp Parse OpenMP pragmas and generate parallel code. ! HELP-NEXT: -fpass-plugin= Load pass plugin from a dynamic shared object file (only with new pass manager). @@ -55,6 +57,8 @@ ! HELP-NEXT: -fstack-arrays Attempt to allocate array temporaries on the stack, no matter their size ! HELP-NEXT: -fsyntax-only Run the preprocessor, parser and semantic analysis stages ! HELP-NEXT: -funderscoring Appends one trailing underscore to external names +! HELP-NEXT: -fversion-loops-for-stride +! HELP-NEXT:Create unit-strided versions of loops ! HELP-NEXT: -fxor-operator Enable .XOR. as a synonym of .NEQV. ! HELP-NEXT: -gline-tables-only Emit debug line number tables only ! HELP-NEXT: -g Generate source-level debug information @@ -146,6 +150,8 @@ ! HELP-FC1-NEXT: -fno-reformat Dump the cooked character stream in -E mode
[PATCH] D141307: Add -f[no-]loop-versioning option
Leporacanthicus updated this revision to Diff 514403. Leporacanthicus added a comment. Rebase only Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D141307/new/ https://reviews.llvm.org/D141307 Files: clang/include/clang/Driver/Options.td clang/lib/Driver/ToolChains/Flang.cpp clang/lib/Driver/ToolChains/Flang.h flang/include/flang/Frontend/CodeGenOptions.def flang/include/flang/Tools/CLOptions.inc flang/lib/Frontend/CompilerInvocation.cpp flang/lib/Frontend/FrontendActions.cpp flang/test/Driver/driver-help-hidden.f90 flang/test/Driver/driver-help.f90 flang/test/Driver/frontend-forwarding.f90 flang/test/Driver/version-loops.f90 Index: flang/test/Driver/version-loops.f90 === --- /dev/null +++ flang/test/Driver/version-loops.f90 @@ -0,0 +1,54 @@ +! Test that flang-new forwards the -f{no-,}version-loops-for-stride +! options correctly to flang-new -fc1 for different variants of optimisation +! and explicit flags. + +! RUN: %flang -### %s -o %t 2>&1 -O3 \ +! RUN: | FileCheck %s + +! RUN: %flang -### %s -o %t 2>&1 -O2 \ +! RUN: | FileCheck %s --check-prefix=CHECK-O2 + +! RUN: %flang -### %s -o %t 2>&1 -O2 -fversion-loops-for-stride \ +! RUN: | FileCheck %s --check-prefix=CHECK-O2-with + +! RUN: %flang -### %s -o %t 2>&1 -O4 \ +! RUN: | FileCheck %s --check-prefix=CHECK-O4 + +! RUN: %flang -### %s -o %t 2>&1 -Ofast \ +! RUN: | FileCheck %s --check-prefix=CHECK-Ofast + +! RUN: %flang -### %s -o %t 2>&1 -Ofast -fno-version-loops-for-stride \ +! RUN: | FileCheck %s --check-prefix=CHECK-Ofast-no + +! RUN: %flang -### %s -o %t 2>&1 -O3 -fno-version-loops-for-stride \ +! RUN: | FileCheck %s --check-prefix=CHECK-O3-no + +! CHECK: "{{.*}}flang-new" "-fc1" +! CHECK-SAME: "-fversion-loops-for-stride" +! CHECK-SAME: "-O3" + +! CHECK-O2: "{{.*}}flang-new" "-fc1" +! CHECK-O2-NOT: "-fversion-loops-for-stride" +! CHECK-O2-SAME: "-O2" + +! CHECK-O2-with: "{{.*}}flang-new" "-fc1" +! CHECK-O2-with-SAME: "-fversion-loops-for-stride" +! CHECK-O2-with-SAME: "-O2" + +! CHECK-O4: "{{.*}}flang-new" "-fc1" +! CHECK-O4-SAME: "-fversion-loops-for-stride" +! CHECK-O4-SAME: "-O3" + +! CHECK-Ofast: "{{.*}}flang-new" "-fc1" +! CHECK-Ofast-SAME: "-ffast-math" +! CHECK-Ofast-SAME: "-fversion-loops-for-stride" +! CHECK-Ofast-SAME: "-O3" + +! CHECK-Ofast-no: "{{.*}}flang-new" "-fc1" +! CHECK-Ofast-no-SAME: "-ffast-math" +! CHECK-Ofast-no-NOT: "-fversion-loops-for-stride" +! CHECK-Ofast-no-SAME: "-O3" + +! CHECK-O3-no: "{{.*}}flang-new" "-fc1" +! CHECK-O3-no-NOT: "-fversion-loops-for-stride" +! CHECK-O3-no-SAME: "-O3" Index: flang/test/Driver/frontend-forwarding.f90 === --- flang/test/Driver/frontend-forwarding.f90 +++ flang/test/Driver/frontend-forwarding.f90 @@ -15,6 +15,8 @@ ! RUN: -fassociative-math \ ! RUN: -freciprocal-math \ ! RUN: -fpass-plugin=Bye%pluginext \ +! RUN: -fversion-loops-for-stride \ +! RUN: -mllvm -print-before-all\ ! RUN: -mllvm -print-before-all \ ! RUN: -save-temps=obj \ ! RUN: -P \ @@ -34,5 +36,6 @@ ! CHECK: "-freciprocal-math" ! CHECK: "-fconvert=little-endian" ! CHECK: "-fpass-plugin=Bye +! CHECK: "-fversion-loops-for-stride" ! CHECK: "-mllvm" "-print-before-all" ! CHECK: "-save-temps=obj" Index: flang/test/Driver/driver-help.f90 === --- flang/test/Driver/driver-help.f90 +++ flang/test/Driver/driver-help.f90 @@ -48,6 +48,8 @@ ! HELP-NEXT: -fno-integrated-as Disable the integrated assembler ! HELP-NEXT: -fno-signed-zeros Allow optimizations that ignore the sign of floating point zeros ! HELP-NEXT: -fno-stack-arrays Allocate array temporaries on the heap (default) +! HELP-NEXT: -fno-version-loops-for-stride +! HELP-NEXT:Do not create unit-strided loops (default) ! HELP-NEXT: -fopenacc Enable OpenACC ! HELP-NEXT: -fopenmp Parse OpenMP pragmas and generate parallel code. ! HELP-NEXT: -fpass-plugin= Load pass plugin from a dynamic shared object file (only with new pass manager). @@ -55,6 +57,8 @@ ! HELP-NEXT: -fstack-arrays Attempt to allocate array temporaries on the stack, no matter their size ! HELP-NEXT: -fsyntax-only Run the preprocessor, parser and semantic analysis stages ! HELP-NEXT: -funderscoring Appends one trailing underscore to external names +! HELP-NEXT: -fversion-loops-for-stride +! HELP-NEXT:Create unit-strided versions of loops ! HELP-NEXT: -fxor-operator Enable .XOR. as a synonym of .NEQV. ! HELP-NEXT: -gline-tables-only Emit debug line number tables only ! HELP-NEXT: -g Generate source-level debug information @@ -146,6 +150,8 @@ ! HELP-FC1-NEXT: -fno-reformat Dump the cooked character stream in -E mode
[PATCH] D141307: Add -f[no-]loop-versioning option
Leporacanthicus updated this revision to Diff 513672. Leporacanthicus added a comment. Remove unnecessary braces in if-statement. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D141307/new/ https://reviews.llvm.org/D141307 Files: clang/include/clang/Driver/Options.td clang/lib/Driver/ToolChains/Flang.cpp clang/lib/Driver/ToolChains/Flang.h flang/include/flang/Frontend/CodeGenOptions.def flang/include/flang/Tools/CLOptions.inc flang/lib/Frontend/CompilerInvocation.cpp flang/lib/Frontend/FrontendActions.cpp flang/test/Driver/driver-help-hidden.f90 flang/test/Driver/driver-help.f90 flang/test/Driver/frontend-forwarding.f90 flang/test/Driver/version-loops.f90 Index: flang/test/Driver/version-loops.f90 === --- /dev/null +++ flang/test/Driver/version-loops.f90 @@ -0,0 +1,54 @@ +! Test that flang-new forwards the -f{no-,}version-loops-for-stride +! options correctly to flang-new -fc1 for different variants of optimisation +! and explicit flags. + +! RUN: %flang -### %s -o %t 2>&1 -O3 \ +! RUN: | FileCheck %s + +! RUN: %flang -### %s -o %t 2>&1 -O2 \ +! RUN: | FileCheck %s --check-prefix=CHECK-O2 + +! RUN: %flang -### %s -o %t 2>&1 -O2 -fversion-loops-for-stride \ +! RUN: | FileCheck %s --check-prefix=CHECK-O2-with + +! RUN: %flang -### %s -o %t 2>&1 -O4 \ +! RUN: | FileCheck %s --check-prefix=CHECK-O4 + +! RUN: %flang -### %s -o %t 2>&1 -Ofast \ +! RUN: | FileCheck %s --check-prefix=CHECK-Ofast + +! RUN: %flang -### %s -o %t 2>&1 -Ofast -fno-version-loops-for-stride \ +! RUN: | FileCheck %s --check-prefix=CHECK-Ofast-no + +! RUN: %flang -### %s -o %t 2>&1 -O3 -fno-version-loops-for-stride \ +! RUN: | FileCheck %s --check-prefix=CHECK-O3-no + +! CHECK: "{{.*}}flang-new" "-fc1" +! CHECK-SAME: "-fversion-loops-for-stride" +! CHECK-SAME: "-O3" + +! CHECK-O2: "{{.*}}flang-new" "-fc1" +! CHECK-O2-NOT: "-fversion-loops-for-stride" +! CHECK-O2-SAME: "-O2" + +! CHECK-O2-with: "{{.*}}flang-new" "-fc1" +! CHECK-O2-with-SAME: "-fversion-loops-for-stride" +! CHECK-O2-with-SAME: "-O2" + +! CHECK-O4: "{{.*}}flang-new" "-fc1" +! CHECK-O4-SAME: "-fversion-loops-for-stride" +! CHECK-O4-SAME: "-O3" + +! CHECK-Ofast: "{{.*}}flang-new" "-fc1" +! CHECK-Ofast-SAME: "-ffast-math" +! CHECK-Ofast-SAME: "-fversion-loops-for-stride" +! CHECK-Ofast-SAME: "-O3" + +! CHECK-Ofast-no: "{{.*}}flang-new" "-fc1" +! CHECK-Ofast-no-SAME: "-ffast-math" +! CHECK-Ofast-no-NOT: "-fversion-loops-for-stride" +! CHECK-Ofast-no-SAME: "-O3" + +! CHECK-O3-no: "{{.*}}flang-new" "-fc1" +! CHECK-O3-no-NOT: "-fversion-loops-for-stride" +! CHECK-O3-no-SAME: "-O3" Index: flang/test/Driver/frontend-forwarding.f90 === --- flang/test/Driver/frontend-forwarding.f90 +++ flang/test/Driver/frontend-forwarding.f90 @@ -15,6 +15,8 @@ ! RUN: -fassociative-math \ ! RUN: -freciprocal-math \ ! RUN: -fpass-plugin=Bye%pluginext \ +! RUN: -fversion-loops-for-stride \ +! RUN: -mllvm -print-before-all\ ! RUN: -mllvm -print-before-all \ ! RUN: -save-temps=obj \ ! RUN: -P \ @@ -34,5 +36,6 @@ ! CHECK: "-freciprocal-math" ! CHECK: "-fconvert=little-endian" ! CHECK: "-fpass-plugin=Bye +! CHECK: "-fversion-loops-for-stride" ! CHECK: "-mllvm" "-print-before-all" ! CHECK: "-save-temps=obj" Index: flang/test/Driver/driver-help.f90 === --- flang/test/Driver/driver-help.f90 +++ flang/test/Driver/driver-help.f90 @@ -48,6 +48,8 @@ ! HELP-NEXT: -fno-integrated-as Disable the integrated assembler ! HELP-NEXT: -fno-signed-zeros Allow optimizations that ignore the sign of floating point zeros ! HELP-NEXT: -fno-stack-arrays Allocate array temporaries on the heap (default) +! HELP-NEXT: -fno-version-loops-for-stride +! HELP-NEXT:Do not create unit-strided loops (default) ! HELP-NEXT: -fopenacc Enable OpenACC ! HELP-NEXT: -fopenmp Parse OpenMP pragmas and generate parallel code. ! HELP-NEXT: -fpass-plugin= Load pass plugin from a dynamic shared object file (only with new pass manager). @@ -55,6 +57,8 @@ ! HELP-NEXT: -fstack-arrays Attempt to allocate array temporaries on the stack, no matter their size ! HELP-NEXT: -fsyntax-only Run the preprocessor, parser and semantic analysis stages ! HELP-NEXT: -funderscoring Appends one trailing underscore to external names +! HELP-NEXT: -fversion-loops-for-stride +! HELP-NEXT:Create unit-strided versions of loops ! HELP-NEXT: -fxor-operator Enable .XOR. as a synonym of .NEQV. ! HELP-NEXT: -gline-tables-only Emit debug line number tables only ! HELP-NEXT: -g Generate source-level debug information @@ -146,6 +150,8 @@ ! HELP-FC1-NEXT: -fno-reformat Dump the
[PATCH] D141307: Add -f[no-]loop-versioning option
awarzynski accepted this revision. awarzynski added a comment. LGTM, thanks! Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D141307/new/ https://reviews.llvm.org/D141307 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D141307: Add -f[no-]loop-versioning option
Leporacanthicus updated this revision to Diff 512929. Leporacanthicus marked 3 inline comments as done. Leporacanthicus added a comment. - Add new function to help clarify the purpose of the options being used. - Add descriptive comment to make function use clearer. - Update tests to make them a more explicit. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D141307/new/ https://reviews.llvm.org/D141307 Files: clang/include/clang/Driver/Options.td clang/lib/Driver/ToolChains/Flang.cpp clang/lib/Driver/ToolChains/Flang.h flang/include/flang/Frontend/CodeGenOptions.def flang/include/flang/Tools/CLOptions.inc flang/lib/Frontend/CompilerInvocation.cpp flang/lib/Frontend/FrontendActions.cpp flang/test/Driver/driver-help-hidden.f90 flang/test/Driver/driver-help.f90 flang/test/Driver/frontend-forwarding.f90 flang/test/Driver/version-loops.f90 Index: flang/test/Driver/version-loops.f90 === --- /dev/null +++ flang/test/Driver/version-loops.f90 @@ -0,0 +1,54 @@ +! Test that flang-new forwards the -f{no-,}version-loops-for-stride +! options correctly to flang-new -fc1 for different variants of optimisation +! and explicit flags. + +! RUN: %flang -### %s -o %t 2>&1 -O3 \ +! RUN: | FileCheck %s + +! RUN: %flang -### %s -o %t 2>&1 -O2 \ +! RUN: | FileCheck %s --check-prefix=CHECK-O2 + +! RUN: %flang -### %s -o %t 2>&1 -O2 -fversion-loops-for-stride \ +! RUN: | FileCheck %s --check-prefix=CHECK-O2-with + +! RUN: %flang -### %s -o %t 2>&1 -O4 \ +! RUN: | FileCheck %s --check-prefix=CHECK-O4 + +! RUN: %flang -### %s -o %t 2>&1 -Ofast \ +! RUN: | FileCheck %s --check-prefix=CHECK-Ofast + +! RUN: %flang -### %s -o %t 2>&1 -Ofast -fno-version-loops-for-stride \ +! RUN: | FileCheck %s --check-prefix=CHECK-Ofast-no + +! RUN: %flang -### %s -o %t 2>&1 -O3 -fno-version-loops-for-stride \ +! RUN: | FileCheck %s --check-prefix=CHECK-O3-no + +! CHECK: "{{.*}}flang-new" "-fc1" +! CHECK-SAME: "-fversion-loops-for-stride" +! CHECK-SAME: "-O3" + +! CHECK-O2: "{{.*}}flang-new" "-fc1" +! CHECK-O2-NOT: "-fversion-loops-for-stride" +! CHECK-O2-SAME: "-O2" + +! CHECK-O2-with: "{{.*}}flang-new" "-fc1" +! CHECK-O2-with-SAME: "-fversion-loops-for-stride" +! CHECK-O2-with-SAME: "-O2" + +! CHECK-O4: "{{.*}}flang-new" "-fc1" +! CHECK-O4-SAME: "-fversion-loops-for-stride" +! CHECK-O4-SAME: "-O3" + +! CHECK-Ofast: "{{.*}}flang-new" "-fc1" +! CHECK-Ofast-SAME: "-ffast-math" +! CHECK-Ofast-SAME: "-fversion-loops-for-stride" +! CHECK-Ofast-SAME: "-O3" + +! CHECK-Ofast-no: "{{.*}}flang-new" "-fc1" +! CHECK-Ofast-no-SAME: "-ffast-math" +! CHECK-Ofast-no-NOT: "-fversion-loops-for-stride" +! CHECK-Ofast-no-SAME: "-O3" + +! CHECK-O3-no: "{{.*}}flang-new" "-fc1" +! CHECK-O3-no-NOT: "-fversion-loops-for-stride" +! CHECK-O3-no-SAME: "-O3" Index: flang/test/Driver/frontend-forwarding.f90 === --- flang/test/Driver/frontend-forwarding.f90 +++ flang/test/Driver/frontend-forwarding.f90 @@ -15,6 +15,8 @@ ! RUN: -fassociative-math \ ! RUN: -freciprocal-math \ ! RUN: -fpass-plugin=Bye%pluginext \ +! RUN: -fversion-loops-for-stride \ +! RUN: -mllvm -print-before-all\ ! RUN: -mllvm -print-before-all \ ! RUN: -save-temps=obj \ ! RUN: -P \ @@ -34,5 +36,6 @@ ! CHECK: "-freciprocal-math" ! CHECK: "-fconvert=little-endian" ! CHECK: "-fpass-plugin=Bye +! CHECK: "-fversion-loops-for-stride" ! CHECK: "-mllvm" "-print-before-all" ! CHECK: "-save-temps=obj" Index: flang/test/Driver/driver-help.f90 === --- flang/test/Driver/driver-help.f90 +++ flang/test/Driver/driver-help.f90 @@ -48,6 +48,8 @@ ! HELP-NEXT: -fno-integrated-as Disable the integrated assembler ! HELP-NEXT: -fno-signed-zeros Allow optimizations that ignore the sign of floating point zeros ! HELP-NEXT: -fno-stack-arrays Allocate array temporaries on the heap (default) +! HELP-NEXT: -fno-version-loops-for-stride +! HELP-NEXT:Do not create unit-strided loops (default) ! HELP-NEXT: -fopenacc Enable OpenACC ! HELP-NEXT: -fopenmp Parse OpenMP pragmas and generate parallel code. ! HELP-NEXT: -fpass-plugin= Load pass plugin from a dynamic shared object file (only with new pass manager). @@ -55,6 +57,8 @@ ! HELP-NEXT: -fstack-arrays Attempt to allocate array temporaries on the stack, no matter their size ! HELP-NEXT: -fsyntax-only Run the preprocessor, parser and semantic analysis stages ! HELP-NEXT: -funderscoring Appends one trailing underscore to external names +! HELP-NEXT: -fversion-loops-for-stride +! HELP-NEXT:Create unit-strided versions of loops ! HELP-NEXT: -fxor-operator Enable .XOR. as a synonym of .NEQV. ! HELP-NEXT: -gline-tables-only Emit
[PATCH] D141307: Add -f[no-]loop-versioning option
Leporacanthicus updated this revision to Diff 512532. Leporacanthicus added a comment. Rebase only. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D141307/new/ https://reviews.llvm.org/D141307 Files: clang/include/clang/Driver/Options.td clang/lib/Driver/ToolChains/Flang.cpp flang/include/flang/Frontend/CodeGenOptions.def flang/include/flang/Tools/CLOptions.inc flang/lib/Frontend/CompilerInvocation.cpp flang/lib/Frontend/FrontendActions.cpp flang/test/Driver/driver-help-hidden.f90 flang/test/Driver/driver-help.f90 flang/test/Driver/frontend-forwarding.f90 flang/test/Driver/version-loops.f90 Index: flang/test/Driver/version-loops.f90 === --- /dev/null +++ flang/test/Driver/version-loops.f90 @@ -0,0 +1,54 @@ +! Test that flang-new forwards the -f{no-,}version-loops-for-stride +! options corredly to flang-new -fc1 for different variants of optimisation +! and explicit flags. + +! RUN: %flang -fsyntax-only -### %s -o %t 2>&1 \ +! RUN: -O3 \ +! RUN: | FileCheck %s + +! RUN: %flang -fsyntax-only -### %s -o %t 2>&1 \ +! RUN: -O2 \ +! RUN: | FileCheck %s --check-prefix=CHECK-O2 + +! RUN: %flang -fsyntax-only -### %s -o %t 2>&1 \ +! RUN: -O2 -fversion-loops-for-stride \ +! RUN: | FileCheck %s --check-prefix=CHECK-O2-with + +! RUN: %flang -fsyntax-only -### %s -o %t 2>&1 \ +! RUN: -O4 \ +! RUN: | FileCheck %s --check-prefix=CHECK-O4 + +! RUN: %flang -fsyntax-only -### %s -o %t 2>&1 \ +! RUN: -Ofast \ +! RUN: | FileCheck %s --check-prefix=CHECK-Ofast + +! RUN: %flang -fsyntax-only -### %s -o %t 2>&1 \ +! RUN: -Ofast -fno-version-loops-for-stride \ +! RUN: | FileCheck %s --check-prefix=CHECK-Ofast-no + +! RUN: %flang -fsyntax-only -### %s -o %t 2>&1 \ +! RUN: -O3 -fno-version-loops-for-stride \ +! RUN: | FileCheck %s --check-prefix=CHECK-O3-no + +! CHECK: "-fversion-loops-for-stride" +! CHECK: "-O3" + +! CHECK-O2-NOT: "-fversion-loops-for-stride" +! CHECK-O2: "-O2" + +! CHECK-O2-with: "-fversion-loops-for-stride" +! CHECK-O2-with: "-O2" + +! CHECK-O4: "-fversion-loops-for-stride" +! CHECK-O4: "-O3" + +! CHECK-Ofast: "-ffast-math" +! CHECK-Ofast: "-fversion-loops-for-stride" +! CHECK-Ofast: "-O3" + +! CHECK-Ofast-no: "-ffast-math" +! CHECK-Ofast-no-NOT: "-fversion-loops-for-stride" +! CHECK-Ofast-no: "-O3" + +! CHECK-O3-no-NOT: "-fversion-loops-for-stride" +! CHECK-O3-no: "-O3" Index: flang/test/Driver/frontend-forwarding.f90 === --- flang/test/Driver/frontend-forwarding.f90 +++ flang/test/Driver/frontend-forwarding.f90 @@ -15,6 +15,8 @@ ! RUN: -fassociative-math \ ! RUN: -freciprocal-math \ ! RUN: -fpass-plugin=Bye%pluginext \ +! RUN: -fversion-loops-for-stride \ +! RUN: -mllvm -print-before-all\ ! RUN: -mllvm -print-before-all \ ! RUN: -save-temps=obj \ ! RUN: -P \ @@ -34,5 +36,6 @@ ! CHECK: "-freciprocal-math" ! CHECK: "-fconvert=little-endian" ! CHECK: "-fpass-plugin=Bye +! CHECK: "-fversion-loops-for-stride" ! CHECK: "-mllvm" "-print-before-all" ! CHECK: "-save-temps=obj" Index: flang/test/Driver/driver-help.f90 === --- flang/test/Driver/driver-help.f90 +++ flang/test/Driver/driver-help.f90 @@ -48,6 +48,8 @@ ! HELP-NEXT: -fno-integrated-as Disable the integrated assembler ! HELP-NEXT: -fno-signed-zeros Allow optimizations that ignore the sign of floating point zeros ! HELP-NEXT: -fno-stack-arrays Allocate array temporaries on the heap (default) +! HELP-NEXT: -fno-version-loops-for-stride +! HELP-NEXT:Do not create unit-strided loops (default) ! HELP-NEXT: -fopenacc Enable OpenACC ! HELP-NEXT: -fopenmp Parse OpenMP pragmas and generate parallel code. ! HELP-NEXT: -fpass-plugin= Load pass plugin from a dynamic shared object file (only with new pass manager). @@ -55,6 +57,8 @@ ! HELP-NEXT: -fstack-arrays Attempt to allocate array temporaries on the stack, no matter their size ! HELP-NEXT: -fsyntax-only Run the preprocessor, parser and semantic analysis stages ! HELP-NEXT: -funderscoring Appends one trailing underscore to external names +! HELP-NEXT: -fversion-loops-for-stride +! HELP-NEXT:Create unit-strided versions of loops ! HELP-NEXT: -fxor-operator Enable .XOR. as a synonym of .NEQV. ! HELP-NEXT: -gline-tables-only Emit debug line number tables only ! HELP-NEXT: -g Generate source-level debug information @@ -143,6 +147,8 @@ ! HELP-FC1-NEXT: -fno-reformat Dump the cooked character stream in -E mode ! HELP-FC1-NEXT: -fno-signed-zeros Allow optimizations that ignore the sign of floating point zeros ! HELP-FC1-NEXT: -fno-stack-arrays Allocate array temporaries on the heap (default) +!
[PATCH] D141307: Add -f[no-]loop-versioning option
awarzynski added a comment. Mats, thanks for working on this! Just a few minor suggestions from me. Comment at: clang/lib/Driver/ToolChains/Flang.cpp:55 +static bool shouldLoopVersion(const ArgList ) { + if (Arg *A = Args.getLastArg(options::OPT_Ofast, options::OPT_O, Could you add a short Docstring, pls? In particular, is the logic implemented by this method consistent with GFortran? Are there any external docs that could be referred to here? Comment at: clang/lib/Driver/ToolChains/Flang.cpp:56 +static bool shouldLoopVersion(const ArgList ) { + if (Arg *A = Args.getLastArg(options::OPT_Ofast, options::OPT_O, + options::OPT_O4, options::OPT_floop_versioning, Please rewrite this to use [[ https://llvm.org/docs/CodingStandards.html#use-early-exits-and-continue-to-simplify-code | early exit ]], e.g.: ``` Arg *LoopVersionOption = Args.getLastArg(options::OPT_Ofast, options::OPT_O, options::OPT_O4, options::OPT_floop_versioning, options::OPT_fno_loop_versioning) if !(LoopVersionOption) return false; // The remaining logic HERE ``` Comment at: clang/lib/Driver/ToolChains/Flang.cpp:109-110 addDebugInfoKind(CmdArgs, DebugInfoKind); + if (shouldLoopVersion(Args)) +CmdArgs.push_back("-fversion-loops-for-stride"); } Would you classify this as a code-gen option? Alongside `-fstack-arrays` and `-flang-experimental-hlfir`? It sound like we could introduce another hook here, `adddCodeGenOptions`? Comment at: flang/test/Driver/version-loops.f90:2 +! Test that flang-new forwards the -f{no-,}version-loops-for-stride +! options corredly to flang-new -fc1 for different variants of optimisation +! and explicit flags. Comment at: flang/test/Driver/version-loops.f90:5 + +! RUN: %flang -fsyntax-only -### %s -o %t 2>&1 \ +! RUN: -O3 \ [nit] If you are using `-###`, then you can just skip `-fsyntax-only` (it doesn't really matter what "action" is requested from the frontend driver). Comment at: flang/test/Driver/version-loops.f90:33-34 + +! CHECK: "-fversion-loops-for-stride" +! CHECK: "-O3" + Similar suggestion for other `CHECK` lines - this will make the test a bit more explicit about the expected output. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D141307/new/ https://reviews.llvm.org/D141307 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D141307: Add -f[no-]loop-versioning option
Leporacanthicus updated this revision to Diff 511416. Leporacanthicus added a comment. Rebase only Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D141307/new/ https://reviews.llvm.org/D141307 Files: clang/include/clang/Driver/Options.td clang/lib/Driver/ToolChains/Flang.cpp flang/include/flang/Frontend/CodeGenOptions.def flang/include/flang/Tools/CLOptions.inc flang/lib/Frontend/CompilerInvocation.cpp flang/lib/Frontend/FrontendActions.cpp flang/test/Driver/driver-help-hidden.f90 flang/test/Driver/driver-help.f90 flang/test/Driver/frontend-forwarding.f90 flang/test/Driver/version-loops.f90 Index: flang/test/Driver/version-loops.f90 === --- /dev/null +++ flang/test/Driver/version-loops.f90 @@ -0,0 +1,54 @@ +! Test that flang-new forwards the -f{no-,}version-loops-for-stride +! options corredly to flang-new -fc1 for different variants of optimisation +! and explicit flags. + +! RUN: %flang -fsyntax-only -### %s -o %t 2>&1 \ +! RUN: -O3 \ +! RUN: | FileCheck %s + +! RUN: %flang -fsyntax-only -### %s -o %t 2>&1 \ +! RUN: -O2 \ +! RUN: | FileCheck %s --check-prefix=CHECK-O2 + +! RUN: %flang -fsyntax-only -### %s -o %t 2>&1 \ +! RUN: -O2 -fversion-loops-for-stride \ +! RUN: | FileCheck %s --check-prefix=CHECK-O2-with + +! RUN: %flang -fsyntax-only -### %s -o %t 2>&1 \ +! RUN: -O4 \ +! RUN: | FileCheck %s --check-prefix=CHECK-O4 + +! RUN: %flang -fsyntax-only -### %s -o %t 2>&1 \ +! RUN: -Ofast \ +! RUN: | FileCheck %s --check-prefix=CHECK-Ofast + +! RUN: %flang -fsyntax-only -### %s -o %t 2>&1 \ +! RUN: -Ofast -fno-version-loops-for-stride \ +! RUN: | FileCheck %s --check-prefix=CHECK-Ofast-no + +! RUN: %flang -fsyntax-only -### %s -o %t 2>&1 \ +! RUN: -O3 -fno-version-loops-for-stride \ +! RUN: | FileCheck %s --check-prefix=CHECK-O3-no + +! CHECK: "-fversion-loops-for-stride" +! CHECK: "-O3" + +! CHECK-O2-NOT: "-fversion-loops-for-stride" +! CHECK-O2: "-O2" + +! CHECK-O2-with: "-fversion-loops-for-stride" +! CHECK-O2-with: "-O2" + +! CHECK-O4: "-fversion-loops-for-stride" +! CHECK-O4: "-O3" + +! CHECK-Ofast: "-ffast-math" +! CHECK-Ofast: "-fversion-loops-for-stride" +! CHECK-Ofast: "-O3" + +! CHECK-Ofast-no: "-ffast-math" +! CHECK-Ofast-no-NOT: "-fversion-loops-for-stride" +! CHECK-Ofast-no: "-O3" + +! CHECK-O3-no-NOT: "-fversion-loops-for-stride" +! CHECK-O3-no: "-O3" Index: flang/test/Driver/frontend-forwarding.f90 === --- flang/test/Driver/frontend-forwarding.f90 +++ flang/test/Driver/frontend-forwarding.f90 @@ -15,6 +15,8 @@ ! RUN: -fassociative-math \ ! RUN: -freciprocal-math \ ! RUN: -fpass-plugin=Bye%pluginext \ +! RUN: -fversion-loops-for-stride \ +! RUN: -mllvm -print-before-all\ ! RUN: -mllvm -print-before-all \ ! RUN: -save-temps=obj \ ! RUN: -P \ @@ -34,5 +36,6 @@ ! CHECK: "-freciprocal-math" ! CHECK: "-fconvert=little-endian" ! CHECK: "-fpass-plugin=Bye +! CHECK: "-fversion-loops-for-stride" ! CHECK: "-mllvm" "-print-before-all" ! CHECK: "-save-temps=obj" Index: flang/test/Driver/driver-help.f90 === --- flang/test/Driver/driver-help.f90 +++ flang/test/Driver/driver-help.f90 @@ -48,6 +48,8 @@ ! HELP-NEXT: -fno-integrated-as Disable the integrated assembler ! HELP-NEXT: -fno-signed-zeros Allow optimizations that ignore the sign of floating point zeros ! HELP-NEXT: -fno-stack-arrays Allocate array temporaries on the heap (default) +! HELP-NEXT: -fno-version-loops-for-stride +! HELP-NEXT:Do not create unit-strided loops (default) ! HELP-NEXT: -fopenacc Enable OpenACC ! HELP-NEXT: -fopenmp Parse OpenMP pragmas and generate parallel code. ! HELP-NEXT: -fpass-plugin= Load pass plugin from a dynamic shared object file (only with new pass manager). @@ -55,6 +57,8 @@ ! HELP-NEXT: -fstack-arrays Attempt to allocate array temporaries on the stack, no matter their size ! HELP-NEXT: -fsyntax-only Run the preprocessor, parser and semantic analysis stages ! HELP-NEXT: -funderscoring Appends one trailing underscore to external names +! HELP-NEXT: -fversion-loops-for-stride +! HELP-NEXT:Create unit-strided versions of loops ! HELP-NEXT: -fxor-operator Enable .XOR. as a synonym of .NEQV. ! HELP-NEXT: -gline-tables-only Emit debug line number tables only ! HELP-NEXT: -g Generate source-level debug information @@ -143,6 +147,8 @@ ! HELP-FC1-NEXT: -fno-reformat Dump the cooked character stream in -E mode ! HELP-FC1-NEXT: -fno-signed-zeros Allow optimizations that ignore the sign of floating point zeros ! HELP-FC1-NEXT: -fno-stack-arrays Allocate array temporaries on the heap (default) +!
[PATCH] D141307: Add -f[no-]loop-versioning option
Leporacanthicus updated this revision to Diff 510756. Leporacanthicus added a comment. Rebase. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D141307/new/ https://reviews.llvm.org/D141307 Files: clang/include/clang/Driver/Options.td clang/lib/Driver/ToolChains/Flang.cpp flang/include/flang/Frontend/CodeGenOptions.def flang/include/flang/Tools/CLOptions.inc flang/lib/Frontend/CompilerInvocation.cpp flang/lib/Frontend/FrontendActions.cpp flang/test/Driver/driver-help-hidden.f90 flang/test/Driver/driver-help.f90 flang/test/Driver/frontend-forwarding.f90 flang/test/Driver/version-loops.f90 Index: flang/test/Driver/version-loops.f90 === --- /dev/null +++ flang/test/Driver/version-loops.f90 @@ -0,0 +1,54 @@ +! Test that flang-new forwards the -f{no-,}version-loops-for-stride +! options corredly to flang-new -fc1 for different variants of optimisation +! and explicit flags. + +! RUN: %flang -fsyntax-only -### %s -o %t 2>&1 \ +! RUN: -O3 \ +! RUN: | FileCheck %s + +! RUN: %flang -fsyntax-only -### %s -o %t 2>&1 \ +! RUN: -O2 \ +! RUN: | FileCheck %s --check-prefix=CHECK-O2 + +! RUN: %flang -fsyntax-only -### %s -o %t 2>&1 \ +! RUN: -O2 -fversion-loops-for-stride \ +! RUN: | FileCheck %s --check-prefix=CHECK-O2-with + +! RUN: %flang -fsyntax-only -### %s -o %t 2>&1 \ +! RUN: -O4 \ +! RUN: | FileCheck %s --check-prefix=CHECK-O4 + +! RUN: %flang -fsyntax-only -### %s -o %t 2>&1 \ +! RUN: -Ofast \ +! RUN: | FileCheck %s --check-prefix=CHECK-Ofast + +! RUN: %flang -fsyntax-only -### %s -o %t 2>&1 \ +! RUN: -Ofast -fno-version-loops-for-stride \ +! RUN: | FileCheck %s --check-prefix=CHECK-Ofast-no + +! RUN: %flang -fsyntax-only -### %s -o %t 2>&1 \ +! RUN: -O3 -fno-version-loops-for-stride \ +! RUN: | FileCheck %s --check-prefix=CHECK-O3-no + +! CHECK: "-fversion-loops-for-stride" +! CHECK: "-O3" + +! CHECK-O2-NOT: "-fversion-loops-for-stride" +! CHECK-O2: "-O2" + +! CHECK-O2-with: "-fversion-loops-for-stride" +! CHECK-O2-with: "-O2" + +! CHECK-O4: "-fversion-loops-for-stride" +! CHECK-O4: "-O3" + +! CHECK-Ofast: "-ffast-math" +! CHECK-Ofast: "-fversion-loops-for-stride" +! CHECK-Ofast: "-O3" + +! CHECK-Ofast-no: "-ffast-math" +! CHECK-Ofast-no-NOT: "-fversion-loops-for-stride" +! CHECK-Ofast-no: "-O3" + +! CHECK-O3-no-NOT: "-fversion-loops-for-stride" +! CHECK-O3-no: "-O3" Index: flang/test/Driver/frontend-forwarding.f90 === --- flang/test/Driver/frontend-forwarding.f90 +++ flang/test/Driver/frontend-forwarding.f90 @@ -15,6 +15,8 @@ ! RUN: -fassociative-math \ ! RUN: -freciprocal-math \ ! RUN: -fpass-plugin=Bye%pluginext \ +! RUN: -fversion-loops-for-stride \ +! RUN: -mllvm -print-before-all\ ! RUN: -mllvm -print-before-all \ ! RUN: -save-temps=obj \ ! RUN: -P \ @@ -34,5 +36,6 @@ ! CHECK: "-freciprocal-math" ! CHECK: "-fconvert=little-endian" ! CHECK: "-fpass-plugin=Bye +! CHECK: "-fversion-loops-for-stride" ! CHECK: "-mllvm" "-print-before-all" ! CHECK: "-save-temps=obj" Index: flang/test/Driver/driver-help.f90 === --- flang/test/Driver/driver-help.f90 +++ flang/test/Driver/driver-help.f90 @@ -48,6 +48,8 @@ ! HELP-NEXT: -fno-integrated-as Disable the integrated assembler ! HELP-NEXT: -fno-signed-zeros Allow optimizations that ignore the sign of floating point zeros ! HELP-NEXT: -fno-stack-arrays Allocate array temporaries on the heap (default) +! HELP-NEXT: -fno-version-loops-for-stride +! HELP-NEXT:Do not create unit-strided loops (default) ! HELP-NEXT: -fopenacc Enable OpenACC ! HELP-NEXT: -fopenmp Parse OpenMP pragmas and generate parallel code. ! HELP-NEXT: -fpass-plugin= Load pass plugin from a dynamic shared object file (only with new pass manager). @@ -55,6 +57,8 @@ ! HELP-NEXT: -fstack-arrays Attempt to allocate array temporaries on the stack, no matter their size ! HELP-NEXT: -fsyntax-only Run the preprocessor, parser and semantic analysis stages ! HELP-NEXT: -funderscoring Appends one trailing underscore to external names +! HELP-NEXT: -fversion-loops-for-stride +! HELP-NEXT:Create unit-strided versions of loops ! HELP-NEXT: -fxor-operator Enable .XOR. as a synonym of .NEQV. ! HELP-NEXT: -gline-tables-only Emit debug line number tables only ! HELP-NEXT: -g Generate source-level debug information @@ -143,6 +147,8 @@ ! HELP-FC1-NEXT: -fno-reformat Dump the cooked character stream in -E mode ! HELP-FC1-NEXT: -fno-signed-zeros Allow optimizations that ignore the sign of floating point zeros ! HELP-FC1-NEXT: -fno-stack-arrays Allocate array temporaries on the heap (default) +!
[PATCH] D141307: Add -f[no-]loop-versioning option
Leporacanthicus updated this revision to Diff 506125. Leporacanthicus added a comment. Rebase and fix conflicts Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D141307/new/ https://reviews.llvm.org/D141307 Files: clang/include/clang/Driver/Options.td clang/lib/Driver/ToolChains/Flang.cpp flang/include/flang/Frontend/CodeGenOptions.def flang/include/flang/Tools/CLOptions.inc flang/lib/Frontend/CompilerInvocation.cpp flang/lib/Frontend/FrontendActions.cpp flang/test/Driver/driver-help-hidden.f90 flang/test/Driver/driver-help.f90 flang/test/Driver/frontend-forwarding.f90 flang/test/Driver/version-loops.f90 Index: flang/test/Driver/version-loops.f90 === --- /dev/null +++ flang/test/Driver/version-loops.f90 @@ -0,0 +1,54 @@ +! Test that flang-new forwards the -f{no-,}version-loops-for-stride +! options corredly to flang-new -fc1 for different variants of optimisation +! and explicit flags. + +! RUN: %flang -fsyntax-only -### %s -o %t 2>&1 \ +! RUN: -O3 \ +! RUN: | FileCheck %s + +! RUN: %flang -fsyntax-only -### %s -o %t 2>&1 \ +! RUN: -O2 \ +! RUN: | FileCheck %s --check-prefix=CHECK-O2 + +! RUN: %flang -fsyntax-only -### %s -o %t 2>&1 \ +! RUN: -O2 -fversion-loops-for-stride \ +! RUN: | FileCheck %s --check-prefix=CHECK-O2-with + +! RUN: %flang -fsyntax-only -### %s -o %t 2>&1 \ +! RUN: -O4 \ +! RUN: | FileCheck %s --check-prefix=CHECK-O4 + +! RUN: %flang -fsyntax-only -### %s -o %t 2>&1 \ +! RUN: -Ofast \ +! RUN: | FileCheck %s --check-prefix=CHECK-Ofast + +! RUN: %flang -fsyntax-only -### %s -o %t 2>&1 \ +! RUN: -Ofast -fno-version-loops-for-stride \ +! RUN: | FileCheck %s --check-prefix=CHECK-Ofast-no + +! RUN: %flang -fsyntax-only -### %s -o %t 2>&1 \ +! RUN: -O3 -fno-version-loops-for-stride \ +! RUN: | FileCheck %s --check-prefix=CHECK-O3-no + +! CHECK: "-fversion-loops-for-stride" +! CHECK: "-O3" + +! CHECK-O2-NOT: "-fversion-loops-for-stride" +! CHECK-O2: "-O2" + +! CHECK-O2-with: "-fversion-loops-for-stride" +! CHECK-O2-with: "-O2" + +! CHECK-O4: "-fversion-loops-for-stride" +! CHECK-O4: "-O3" + +! CHECK-Ofast: "-ffast-math" +! CHECK-Ofast: "-fversion-loops-for-stride" +! CHECK-Ofast: "-O3" + +! CHECK-Ofast-no: "-ffast-math" +! CHECK-Ofast-no-NOT: "-fversion-loops-for-stride" +! CHECK-Ofast-no: "-O3" + +! CHECK-O3-no-NOT: "-fversion-loops-for-stride" +! CHECK-O3-no: "-O3" Index: flang/test/Driver/frontend-forwarding.f90 === --- flang/test/Driver/frontend-forwarding.f90 +++ flang/test/Driver/frontend-forwarding.f90 @@ -15,6 +15,7 @@ ! RUN: -fassociative-math \ ! RUN: -freciprocal-math \ ! RUN: -fpass-plugin=Bye%pluginext \ +! RUN: -fversion-loops-for-stride \ ! RUN: -mllvm -print-before-all\ ! RUN: -P \ ! RUN: | FileCheck %s @@ -33,4 +34,5 @@ ! CHECK: "-freciprocal-math" ! CHECK: "-fconvert=little-endian" ! CHECK: "-fpass-plugin=Bye +! CHECK: "-fversion-loops-for-stride" ! CHECK: "-mllvm" "-print-before-all" Index: flang/test/Driver/driver-help.f90 === --- flang/test/Driver/driver-help.f90 +++ flang/test/Driver/driver-help.f90 @@ -48,6 +48,8 @@ ! HELP-NEXT: -fno-integrated-as Disable the integrated assembler ! HELP-NEXT: -fno-signed-zeros Allow optimizations that ignore the sign of floating point zeros ! HELP-NEXT: -fno-stack-arrays Allocate array temporaries on the heap (default) +! HELP-NEXT: -fno-version-loops-for-stride +! HELP-NEXT:Do not create unit-strided loops (default) ! HELP-NEXT: -fopenacc Enable OpenACC ! HELP-NEXT: -fopenmp Parse OpenMP pragmas and generate parallel code. ! HELP-NEXT: -fpass-plugin= Load pass plugin from a dynamic shared object file (only with new pass manager). @@ -55,6 +57,8 @@ ! HELP-NEXT: -fstack-arrays Attempt to allocate array temporaries on the stack, no matter their size ! HELP-NEXT: -fsyntax-only Run the preprocessor, parser and semantic analysis stages ! HELP-NEXT: -funderscoring Appends one trailing underscore to external names +! HELP-NEXT: -fversion-loops-for-stride +! HELP-NEXT:Create unit-strided versions of loops ! HELP-NEXT: -fxor-operator Enable .XOR. as a synonym of .NEQV. ! HELP-NEXT: -help Display available options ! HELP-NEXT: -IAdd directory to the end of the list of include search paths @@ -141,6 +145,8 @@ ! HELP-FC1-NEXT: -fno-reformat Dump the cooked character stream in -E mode ! HELP-FC1-NEXT: -fno-signed-zeros Allow optimizations that ignore the sign of floating point zeros ! HELP-FC1-NEXT: -fno-stack-arrays Allocate array temporaries on the heap (default) +! HELP-FC1-NEXT: -fno-version-loops-for-stride +!
[PATCH] D141307: Add -f[no-]loop-versioning option
tblah accepted this revision. tblah added a comment. This revision is now accepted and ready to land. Looks good to me Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D141307/new/ https://reviews.llvm.org/D141307 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D141307: Add -f[no-]loop-versioning option
Leporacanthicus updated this revision to Diff 503459. Leporacanthicus marked an inline comment as done. Leporacanthicus added a comment. Fix copied comment to reflect the new content. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D141307/new/ https://reviews.llvm.org/D141307 Files: clang/include/clang/Driver/Options.td clang/lib/Driver/ToolChains/Flang.cpp flang/include/flang/Frontend/CodeGenOptions.def flang/include/flang/Tools/CLOptions.inc flang/lib/Frontend/CompilerInvocation.cpp flang/lib/Frontend/FrontendActions.cpp flang/test/Driver/driver-help-hidden.f90 flang/test/Driver/driver-help.f90 flang/test/Driver/frontend-forwarding.f90 flang/test/Driver/version-loops.f90 Index: flang/test/Driver/version-loops.f90 === --- /dev/null +++ flang/test/Driver/version-loops.f90 @@ -0,0 +1,54 @@ +! Test that flang-new forwards the -f{no-,}version-loops-for-stride +! options corredly to flang-new -fc1 for different variants of optimisation +! and explicit flags. + +! RUN: %flang -fsyntax-only -### %s -o %t 2>&1 \ +! RUN: -O3 \ +! RUN: | FileCheck %s + +! RUN: %flang -fsyntax-only -### %s -o %t 2>&1 \ +! RUN: -O2 \ +! RUN: | FileCheck %s --check-prefix=CHECK-O2 + +! RUN: %flang -fsyntax-only -### %s -o %t 2>&1 \ +! RUN: -O2 -fversion-loops-for-stride \ +! RUN: | FileCheck %s --check-prefix=CHECK-O2-with + +! RUN: %flang -fsyntax-only -### %s -o %t 2>&1 \ +! RUN: -O4 \ +! RUN: | FileCheck %s --check-prefix=CHECK-O4 + +! RUN: %flang -fsyntax-only -### %s -o %t 2>&1 \ +! RUN: -Ofast \ +! RUN: | FileCheck %s --check-prefix=CHECK-Ofast + +! RUN: %flang -fsyntax-only -### %s -o %t 2>&1 \ +! RUN: -Ofast -fno-version-loops-for-stride \ +! RUN: | FileCheck %s --check-prefix=CHECK-Ofast-no + +! RUN: %flang -fsyntax-only -### %s -o %t 2>&1 \ +! RUN: -O3 -fno-version-loops-for-stride \ +! RUN: | FileCheck %s --check-prefix=CHECK-O3-no + +! CHECK: "-fversion-loops-for-stride" +! CHECK: "-O3" + +! CHECK-O2-NOT: "-fversion-loops-for-stride" +! CHECK-O2: "-O2" + +! CHECK-O2-with: "-fversion-loops-for-stride" +! CHECK-O2-with: "-O2" + +! CHECK-O4: "-fversion-loops-for-stride" +! CHECK-O4: "-O3" + +! CHECK-Ofast: "-ffast-math" +! CHECK-Ofast: "-fversion-loops-for-stride" +! CHECK-Ofast: "-O3" + +! CHECK-Ofast-no: "-ffast-math" +! CHECK-Ofast-no-NOT: "-fversion-loops-for-stride" +! CHECK-Ofast-no: "-O3" + +! CHECK-O3-no-NOT: "-fversion-loops-for-stride" +! CHECK-O3-no: "-O3" Index: flang/test/Driver/frontend-forwarding.f90 === --- flang/test/Driver/frontend-forwarding.f90 +++ flang/test/Driver/frontend-forwarding.f90 @@ -15,6 +15,7 @@ ! RUN: -fassociative-math \ ! RUN: -freciprocal-math \ ! RUN: -fpass-plugin=Bye%pluginext \ +! RUN: -fversion-loops-for-stride \ ! RUN: -mllvm -print-before-all\ ! RUN: -P \ ! RUN: | FileCheck %s @@ -33,4 +34,5 @@ ! CHECK: "-freciprocal-math" ! CHECK: "-fconvert=little-endian" ! CHECK: "-fpass-plugin=Bye +! CHECK: "-fversion-loops-for-stride" ! CHECK: "-mllvm" "-print-before-all" Index: flang/test/Driver/driver-help.f90 === --- flang/test/Driver/driver-help.f90 +++ flang/test/Driver/driver-help.f90 @@ -46,6 +46,8 @@ ! HELP-NEXT: -fno-integrated-as Disable the integrated assembler ! HELP-NEXT: -fno-signed-zeros Allow optimizations that ignore the sign of floating point zeros ! HELP-NEXT: -fno-stack-arrays Allocate array temporaries on the heap (default) +! HELP-NEXT: -fno-version-loops-for-stride +! HELP-NEXT:Do not create unit-strided loops (default) ! HELP-NEXT: -fopenacc Enable OpenACC ! HELP-NEXT: -fopenmp Parse OpenMP pragmas and generate parallel code. ! HELP-NEXT: -fpass-plugin= Load pass plugin from a dynamic shared object file (only with new pass manager). @@ -53,6 +55,8 @@ ! HELP-NEXT: -fstack-arrays Attempt to allocate array temporaries on the stack, no matter their size ! HELP-NEXT: -fsyntax-only Run the preprocessor, parser and semantic analysis stages ! HELP-NEXT: -funderscoring Appends one trailing underscore to external names +! HELP-NEXT: -fversion-loops-for-stride +! HELP-NEXT:Create unit-strided versions of loops ! HELP-NEXT: -fxor-operator Enable .XOR. as a synonym of .NEQV. ! HELP-NEXT: -help Display available options ! HELP-NEXT: -IAdd directory to the end of the list of include search paths @@ -137,6 +141,8 @@ ! HELP-FC1-NEXT: -fno-reformat Dump the cooked character stream in -E mode ! HELP-FC1-NEXT: -fno-signed-zeros Allow optimizations that ignore the sign of floating point zeros ! HELP-FC1-NEXT: -fno-stack-arrays Allocate array temporaries on the heap
[PATCH] D141307: Add -f[no-]loop-versioning option
Leporacanthicus marked an inline comment as done. Leporacanthicus added inline comments. Comment at: clang/lib/Driver/ToolChains/Flang.cpp:69 + Arg *loopVersioning = + Args.getLastArg(options::OPT_Ofast, options::OPT_floop_versioning, + options::OPT_fno_loop_versioning); tblah wrote: > Does GFortran only enable this with -Ofast? I would have thought this would > be an -On thing because it doesn't impact precision. No, good point. Comment at: flang/include/flang/Frontend/CodeGenOptions.def:27 +CODEGENOPT(LoopVersioning, 1, 0) ///< PIC level of the LLVM module. CODEGENOPT(PICLevel, 2, 0) ///< PIC level of the LLVM module. tblah wrote: > nit: comment Darn, missed fixing this. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D141307/new/ https://reviews.llvm.org/D141307 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D141307: Add -f[no-]loop-versioning option
Leporacanthicus updated this revision to Diff 503360. Leporacanthicus added a comment. Herald added a reviewer: sscalpone. Updates based on review comments: - Add tests. - Enable on -O3 Also changed the name to match gfortran. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D141307/new/ https://reviews.llvm.org/D141307 Files: clang/include/clang/Driver/Options.td clang/lib/Driver/ToolChains/Flang.cpp flang/include/flang/Frontend/CodeGenOptions.def flang/include/flang/Tools/CLOptions.inc flang/lib/Frontend/CompilerInvocation.cpp flang/lib/Frontend/FrontendActions.cpp flang/test/Driver/driver-help-hidden.f90 flang/test/Driver/driver-help.f90 flang/test/Driver/frontend-forwarding.f90 flang/test/Driver/version-loops.f90 Index: flang/test/Driver/version-loops.f90 === --- /dev/null +++ flang/test/Driver/version-loops.f90 @@ -0,0 +1,54 @@ +! Test that flang-new forwards the -f{no-,}version-loops-for-stride +! options corredly to flang-new -fc1 for different variants of optimisation +! and explicit flags. + +! RUN: %flang -fsyntax-only -### %s -o %t 2>&1 \ +! RUN: -O3 \ +! RUN: | FileCheck %s + +! RUN: %flang -fsyntax-only -### %s -o %t 2>&1 \ +! RUN: -O2 \ +! RUN: | FileCheck %s --check-prefix=CHECK-O2 + +! RUN: %flang -fsyntax-only -### %s -o %t 2>&1 \ +! RUN: -O2 -fversion-loops-for-stride \ +! RUN: | FileCheck %s --check-prefix=CHECK-O2-with + +! RUN: %flang -fsyntax-only -### %s -o %t 2>&1 \ +! RUN: -O4 \ +! RUN: | FileCheck %s --check-prefix=CHECK-O4 + +! RUN: %flang -fsyntax-only -### %s -o %t 2>&1 \ +! RUN: -Ofast \ +! RUN: | FileCheck %s --check-prefix=CHECK-Ofast + +! RUN: %flang -fsyntax-only -### %s -o %t 2>&1 \ +! RUN: -Ofast -fno-version-loops-for-stride \ +! RUN: | FileCheck %s --check-prefix=CHECK-Ofast-no + +! RUN: %flang -fsyntax-only -### %s -o %t 2>&1 \ +! RUN: -O3 -fno-version-loops-for-stride \ +! RUN: | FileCheck %s --check-prefix=CHECK-O3-no + +! CHECK: "-fversion-loops-for-stride" +! CHECK: "-O3" + +! CHECK-O2-NOT: "-fversion-loops-for-stride" +! CHECK-O2: "-O2" + +! CHECK-O2-with: "-fversion-loops-for-stride" +! CHECK-O2-with: "-O2" + +! CHECK-O4: "-fversion-loops-for-stride" +! CHECK-O4: "-O3" + +! CHECK-Ofast: "-ffast-math" +! CHECK-Ofast: "-fversion-loops-for-stride" +! CHECK-Ofast: "-O3" + +! CHECK-Ofast-no: "-ffast-math" +! CHECK-Ofast-no-NOT: "-fversion-loops-for-stride" +! CHECK-Ofast-no: "-O3" + +! CHECK-O3-no-NOT: "-fversion-loops-for-stride" +! CHECK-O3-no: "-O3" Index: flang/test/Driver/frontend-forwarding.f90 === --- flang/test/Driver/frontend-forwarding.f90 +++ flang/test/Driver/frontend-forwarding.f90 @@ -15,6 +15,7 @@ ! RUN: -fassociative-math \ ! RUN: -freciprocal-math \ ! RUN: -fpass-plugin=Bye%pluginext \ +! RUN: -fversion-loops-for-stride \ ! RUN: -mllvm -print-before-all\ ! RUN: -P \ ! RUN: | FileCheck %s @@ -33,4 +34,5 @@ ! CHECK: "-freciprocal-math" ! CHECK: "-fconvert=little-endian" ! CHECK: "-fpass-plugin=Bye +! CHECK: "-fversion-loops-for-stride" ! CHECK: "-mllvm" "-print-before-all" Index: flang/test/Driver/driver-help.f90 === --- flang/test/Driver/driver-help.f90 +++ flang/test/Driver/driver-help.f90 @@ -46,6 +46,8 @@ ! HELP-NEXT: -fno-integrated-as Disable the integrated assembler ! HELP-NEXT: -fno-signed-zeros Allow optimizations that ignore the sign of floating point zeros ! HELP-NEXT: -fno-stack-arrays Allocate array temporaries on the heap (default) +! HELP-NEXT: -fno-version-loops-for-stride +! HELP-NEXT:Do not create unit-strided loops (default) ! HELP-NEXT: -fopenacc Enable OpenACC ! HELP-NEXT: -fopenmp Parse OpenMP pragmas and generate parallel code. ! HELP-NEXT: -fpass-plugin= Load pass plugin from a dynamic shared object file (only with new pass manager). @@ -53,6 +55,8 @@ ! HELP-NEXT: -fstack-arrays Attempt to allocate array temporaries on the stack, no matter their size ! HELP-NEXT: -fsyntax-only Run the preprocessor, parser and semantic analysis stages ! HELP-NEXT: -funderscoring Appends one trailing underscore to external names +! HELP-NEXT: -fversion-loops-for-stride +! HELP-NEXT:Create unit-strided versions of loops ! HELP-NEXT: -fxor-operator Enable .XOR. as a synonym of .NEQV. ! HELP-NEXT: -help Display available options ! HELP-NEXT: -IAdd directory to the end of the list of include search paths @@ -137,6 +141,8 @@ ! HELP-FC1-NEXT: -fno-reformat Dump the cooked character stream in -E mode ! HELP-FC1-NEXT: -fno-signed-zeros Allow optimizations that ignore the sign of floating point zeros ! HELP-FC1-NEXT: -fno-stack-arrays
[PATCH] D141307: Add -f[no-]loop-versioning option
tblah added a comment. Please could you add tests for the flag forwarding logic in flang/tests/Driver/frontend-forwarding.f90. For example see https://reviews.llvm.org/rGd0d4b635786d510cd919cadbeb7e5e19983242cf Comment at: clang/lib/Driver/ToolChains/Flang.cpp:69 + Arg *loopVersioning = + Args.getLastArg(options::OPT_Ofast, options::OPT_floop_versioning, + options::OPT_fno_loop_versioning); Does GFortran only enable this with -Ofast? I would have thought this would be an -On thing because it doesn't impact precision. Comment at: flang/include/flang/Frontend/CodeGenOptions.def:27 +CODEGENOPT(LoopVersioning, 1, 0) ///< PIC level of the LLVM module. CODEGENOPT(PICLevel, 2, 0) ///< PIC level of the LLVM module. nit: comment Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D141307/new/ https://reviews.llvm.org/D141307 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits