Skip to content

Commit 49d6ba4

Browse files
MaskRaymahesh-attarde
authored andcommitted
[Driver] Make -fvectorize and -fslp-vectorize override -O group options (llvm#161032)
`clang -fno-slp-vectorize -O2` incorrectly enabled CC1 -vectorize-slp. Make -fvectorize and -fslp-vectorize properly override -O, following the convention. Fix llvm#160633
1 parent ef30ca3 commit 49d6ba4

File tree

3 files changed

+7
-11
lines changed

3 files changed

+7
-11
lines changed

clang/lib/Driver/ToolChains/CommonArgs.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3346,20 +3346,16 @@ bool tools::shouldEnableVectorizerAtOLevel(const ArgList &Args, bool isSlpVec) {
33463346
void tools::handleVectorizeLoopsArgs(const ArgList &Args,
33473347
ArgStringList &CmdArgs) {
33483348
bool EnableVec = shouldEnableVectorizerAtOLevel(Args, false);
3349-
OptSpecifier vectorizeAliasOption =
3350-
EnableVec ? options::OPT_O_Group : options::OPT_fvectorize;
3351-
if (Args.hasFlag(options::OPT_fvectorize, vectorizeAliasOption,
3352-
options::OPT_fno_vectorize, EnableVec))
3349+
if (Args.hasFlag(options::OPT_fvectorize, options::OPT_fno_vectorize,
3350+
EnableVec))
33533351
CmdArgs.push_back("-vectorize-loops");
33543352
}
33553353

33563354
void tools::handleVectorizeSLPArgs(const ArgList &Args,
33573355
ArgStringList &CmdArgs) {
33583356
bool EnableSLPVec = shouldEnableVectorizerAtOLevel(Args, true);
3359-
OptSpecifier SLPVectAliasOption =
3360-
EnableSLPVec ? options::OPT_O_Group : options::OPT_fslp_vectorize;
3361-
if (Args.hasFlag(options::OPT_fslp_vectorize, SLPVectAliasOption,
3362-
options::OPT_fno_slp_vectorize, EnableSLPVec))
3357+
if (Args.hasFlag(options::OPT_fslp_vectorize, options::OPT_fno_slp_vectorize,
3358+
EnableSLPVec))
33633359
CmdArgs.push_back("-vectorize-slp");
33643360
}
33653361

clang/test/Driver/Ofast.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// RUN: %clang -c -O2 -Ofast -### %s 2>&1 | FileCheck -check-prefix=CHECK-OFAST %s
33
// RUN: %clang -c -fno-fast-math -Ofast -### %s 2>&1 | FileCheck -check-prefix=CHECK-OFAST %s
44
// RUN: %clang -c -fno-strict-aliasing -Ofast -### %s 2>&1 | FileCheck -check-prefix=CHECK-OFAST %s
5-
// RUN: %clang -c -fno-vectorize -Ofast -### %s 2>&1 | FileCheck -check-prefix=CHECK-OFAST %s
5+
// RUN: %clang -c -fno-vectorize -Ofast -### %s 2>&1 | FileCheck -check-prefix=CHECK-OFAST-NO-VECTORIZE %s
66
// RUN: %clang -c -Ofast -O2 -### -Werror %s 2>&1 | FileCheck -check-prefix=CHECK-OFAST-O2 \
77
// RUN: %if target={{.*-windows-msvc.*}} %{ --check-prefix=CHECK-OFAST-O2-ALIASING-MSVC %} \
88
// RUN: %else %{ --check-prefix=CHECK-OFAST-O2-ALIASING %} %s

clang/test/Driver/clang_f_opts.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@
156156
// RUN: %clang -### -S -O2 %s 2>&1 | FileCheck -check-prefix=CHECK-VECTORIZE %s
157157
// RUN: %clang -### -S -Os %s 2>&1 | FileCheck -check-prefix=CHECK-VECTORIZE %s
158158
// RUN: %clang -### -S -O3 %s 2>&1 | FileCheck -check-prefix=CHECK-VECTORIZE %s
159-
// RUN: %clang -### -S -fno-vectorize -O3 %s 2>&1 | FileCheck -check-prefix=CHECK-VECTORIZE %s
159+
// RUN: %clang -### -S -fno-vectorize -O3 %s 2>&1 | FileCheck -check-prefix=CHECK-NO-VECTORIZE %s
160160
// RUN: %clang -### -S -O1 -fvectorize %s 2>&1 | FileCheck -check-prefix=CHECK-VECTORIZE %s
161161
// RUN: %clang -### -S -Ofast %s 2>&1 | FileCheck -check-prefix=CHECK-VECTORIZE %s
162162
// RUN: %clang -### -S %s 2>&1 | FileCheck -check-prefix=CHECK-NO-VECTORIZE %s
@@ -179,7 +179,7 @@
179179
// RUN: %clang -### -S -Os %s 2>&1 | FileCheck -check-prefix=CHECK-SLP-VECTORIZE %s
180180
// RUN: %clang -### -S -Oz %s 2>&1 | FileCheck -check-prefix=CHECK-SLP-VECTORIZE %s
181181
// RUN: %clang -### -S -O3 %s 2>&1 | FileCheck -check-prefix=CHECK-SLP-VECTORIZE %s
182-
// RUN: %clang -### -S -fno-slp-vectorize -O3 %s 2>&1 | FileCheck -check-prefix=CHECK-SLP-VECTORIZE %s
182+
// RUN: %clang -### -S -fno-slp-vectorize -O3 %s 2>&1 | FileCheck -check-prefix=CHECK-NO-SLP-VECTORIZE %s
183183
// RUN: %clang -### -S -O1 -fslp-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-SLP-VECTORIZE %s
184184
// RUN: %clang -### -S -Ofast %s 2>&1 | FileCheck -check-prefix=CHECK-SLP-VECTORIZE %s
185185
// RUN: %clang -### -S %s 2>&1 | FileCheck -check-prefix=CHECK-NO-SLP-VECTORIZE %s

0 commit comments

Comments
 (0)