public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug other/104683] New: -march=haswell generates invalid instructions on Celeron Haswell CPUs
@ 2022-02-25  2:22 pc-gcc22 at crowcastle dot net
  2022-02-25  8:27 ` [Bug target/104683] " rguenth at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: pc-gcc22 at crowcastle dot net @ 2022-02-25  2:22 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104683

            Bug ID: 104683
           Summary: -march=haswell generates invalid instructions on
                    Celeron Haswell CPUs
           Product: gcc
           Version: 10.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: other
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pc-gcc22 at crowcastle dot net
  Target Milestone: ---

Many of the -march options enable instruction types like AVX that are not
available on Pentium and Celeron processors in that family.

I encountered this on a Haswell Celeron system running gcc 10.3.1.  I suspect
this is the same on many other versions.

gcc --version
gcc (Gentoo 10.3.1_p20211126 p0) 10.3.1 20211126

diff <(gcc -march=haswell -Q --help=target) <(gcc -march=native -Q
--help=target)
12c12
<   -mabm                                       [disabled]
---
>   -mabm                                       [enabled]
26,27c26,27
<   -mavx                                       [enabled]
<   -mavx2                                      [enabled]
---
>   -mavx                                       [disabled]
>   -mavx2                                      [disabled]
48,49c48,49
<   -mbmi                                       [enabled]
<   -mbmi2                                      [enabled]
---
>   -mbmi                                       [disabled]
>   -mbmi2                                      [disabled]
65c65
<   -mf16c                                      [enabled]
---
>   -mf16c                                      [disabled]
70c70
<   -mfma                                       [enabled]
---
>   -mfma                                       [disabled]
186c186
<   -mxsave                                     [enabled]
---
>   -mxsave                                     [disabled]
188c188
<   -mxsaveopt                                  [enabled]
---
>   -mxsaveopt                                  [disabled]

Fortunately, -march=native is fine, but I encountered a project that detects
the processor family and was setting -march=haswell, which failed with illegal
instructions.

While I would argue that -march=[family] should compile only using instructions
available for all processors in [family], I could also see an argument for this
being a documentation bug where the definition for -march=[family] should warn
that it will enable features only available on some CPUs in that family, which
is not what many users would expect.  (There might be cause for separate -march
definitions for lower-end processors, but I don't have brilliant ideas for
syntax, and that might be just adding too much complexity.)

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-02-25 14:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-25  2:22 [Bug other/104683] New: -march=haswell generates invalid instructions on Celeron Haswell CPUs pc-gcc22 at crowcastle dot net
2022-02-25  8:27 ` [Bug target/104683] " rguenth at gcc dot gnu.org
2022-02-25 10:32 ` rguenth at gcc dot gnu.org
2022-02-25 10:38 ` rguenth at gcc dot gnu.org
2022-02-25 14:37 ` pc-gcc22 at crowcastle dot net

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).