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

Martin J. O'Riordan via cfe-dev cfe-dev at lists.llvm.org
Thu Mar 1 10:27:24 PST 2018


No, I’m wrong.  I think that bug is actually in ‘hasFlag’ itself.  In ‘llvm/lib/Option/ArgList.cpp’ line #70:

 

    bool ArgList::hasFlag(OptSpecifier Pos, OptSpecifier PosAlias, OptSpecifier Neg,

                          bool Default) const {

      if (Arg *A = getLastArg(Pos, PosAlias, Neg))

        return A->getOption().matches(Pos) || A->getOption().matches(PosAlias);

      return Default;

    }

 

This doesn’t match when ‘Neg’ is matched, and should probably be:

 

    bool ArgList::hasFlag(OptSpecifier Pos, OptSpecifier PosAlias, OptSpecifier Neg,

                          bool Default) const {

      if (Arg *A = getLastArg(Pos, PosAlias, Neg))

        return A->getOption().matches(Pos) || A->getOption().matches(PosAlias);

      else

        return !A->getOption().matches(Neg) && Default;

    }

 

So the logic in ‘CLang.cpp’ looks valid.  I’ve posted this to LLVM-Dev.

 

Thanks again,

 

            MartinO

 

From: Martin J. O'Riordan [mailto:MartinO at theheart.ie] 
Sent: 01 March 2018 18:15
To: 'LLVM Developers' <llvm-dev at lists.llvm.org>; 'Richard Smith' <richard at metafoo.co.uk>
Subject: RE: [cfe-dev] Disabling vectorisation at '-O3'

 

Yes, it looks like passing ‘EnableVec’ and ‘EnableSLPVec’ to ‘Args.hasFlag’ should be replaced with ‘false’ and then it has the expected behaviour.

 

            MartinO

 

From: cfe-dev [mailto:cfe-dev-bounces at lists.llvm.org] On Behalf Of Martin J. O'Riordan via cfe-dev
Sent: 01 March 2018 18:02
To: 'Richard Smith' <richard at metafoo.co.uk <mailto:richard at metafoo.co.uk> >
Cc: 'Clang Dev' <cfe-dev at lists.llvm.org <mailto:cfe-dev at lists.llvm.org> >
Subject: Re: [cfe-dev] Disabling vectorisation at '-O3'

 

Thanks Richard, I’ll do that - and I can add it as a bug.  It’s almost certainly easy enough to fix, but I wanted to be sure that I wasn’t just making a naïve mistake.

 

            MartinO

 

From: Richard Smith [mailto:richard at metafoo.co.uk] 
Sent: 01 March 2018 17:44
To: Martin J. O'Riordan <MartinO at theheart.ie <mailto:MartinO at theheart.ie> >
Cc: Clang Dev <cfe-dev at lists.llvm.org <mailto:cfe-dev at lists.llvm.org> >
Subject: Re: [cfe-dev] Disabling vectorisation at '-O3'

 

On 1 Mar 2018 09:16, "Martin J. O'Riordan via cfe-dev" <cfe-dev at lists.llvm.org <mailto: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):

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.

 

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


More information about the cfe-dev mailing list