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

Richard Smith via cfe-dev cfe-dev at lists.llvm.org
Thu Mar 1 09:43:40 PST 2018


On 1 Mar 2018 09:16, "Martin J. O'Riordan via cfe-dev" <
cfe-dev at lists.llvm.org> wrote:

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.


This looks like a bug to me; I'd expect -fno-* to override the -O flag
rather than meaning "use the default for this -O level". I'd suggest you
look up who added these flags and check with them to make sure this wasn't
the intent (it it was, we'll need further discussion), then fix the driver
to do the "obvious" thing.

Thanks,



            MartinO



_______________________________________________
cfe-dev mailing list
cfe-dev at lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20180301/1f89b80e/attachment.html>


More information about the cfe-dev mailing list