[cfe-dev] Disabling vectorisation at '-O3'

Martin J. O'Riordan via cfe-dev cfe-dev at lists.llvm.org
Thu Mar 1 09:16:21 PST 2018


Hi CFE-Devs,

 

While debugging a problem in our back-end, I want to temporarily remove JUST
'-vectorize' and '-vectorize-slp' from the flags passed with '-cc1', but I
want to leave all the other command-line options the same.  But when I use:

 

clang -S -O3 -fno-vectorize -fno-slp-vectorize foo.c

 

it is still inserting '-vectorize -vectorize-slp'.  The code in 'Clang.cpp'
for this is at line #4858 (on the v6.0 branch):

 

  // 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.

  bool EnableVec = shouldEnableVectorizerAtOLevel(Args, false);

  OptSpecifier VectorizeAliasOption =

      EnableVec ? options::OPT_O_Group : options::OPT_fvectorize;

  if (Args.hasFlag(options::OPT_fvectorize, VectorizeAliasOption,

                   options::OPT_fno_vectorize, EnableVec))

    CmdArgs.push_back("-vectorize-loops");

 

  // -fslp-vectorize is enabled based on the optimization level selected.

  bool EnableSLPVec = shouldEnableVectorizerAtOLevel(Args, true);

  OptSpecifier SLPVectAliasOption =

      EnableSLPVec ? options::OPT_O_Group : options::OPT_fslp_vectorize;

  if (Args.hasFlag(options::OPT_fslp_vectorize, SLPVectAliasOption,

                   options::OPT_fno_slp_vectorize, EnableSLPVec))

    CmdArgs.push_back("-vectorize-slp");

 

but this is ignoring the '-fno-*' flags and overriding because of the
presence of '-O3' and the defaults for '-O3'.

 

Am I just using 'clang' incorrectly, and if so, how can I achieve what I am
trying to achieve?  I don't want to use '-O0' or '-O1' because I still want
all of the other options passed as usual with '-cc1' as would normally be
passed with '-O3'.  I am not just debugging one file, but would like to
build hundreds of sources with the amended options by just changing some
variables in the Makefiles to see what the impact is.

 

Thanks,

 

            MartinO

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20180301/9e739e71/attachment.html>


More information about the cfe-dev mailing list