Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 95605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T23:41:04+00:00 2026-05-10T23:41:04+00:00

The v4 series of the gcc compiler can automatically vectorize loops using the SIMD

  • 0

The v4 series of the gcc compiler can automatically vectorize loops using the SIMD processor on some modern CPUs, such as the AMD Athlon or Intel Pentium/Core chips. How is this done?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T23:41:04+00:00Added an answer on May 10, 2026 at 11:41 pm

    The original page offers details on getting gcc to automatically vectorize loops, including a few examples:

    http://gcc.gnu.org/projects/tree-ssa/vectorization.html

    While the examples are great, it turns out the syntax for calling those options with latest GCC seems to have changed a bit, see now:

    • https://gcc.gnu.org/onlinedocs/gcc/Developer-Options.html#index-fopt-info

    In summary, the following options will work for x86 chips with SSE2, giving a log of loops that have been vectorized:

    gcc -O2 -ftree-vectorize -msse2 -mfpmath=sse -ftree-vectorizer-verbose=5 

    Note that -msse is also a possibility, but it will only vectorize loops using floats, not doubles or ints. (SSE2 is baseline for x86-64. For 32-bit code use -mfpmath=sse as well. That’s the default for 64-bit but not 32-bit.)


    Modern versions of GCC enable -ftree-vectorize at -O3 so just use that in GCC4.x and later:

    gcc   -O3 -msse2 -mfpmath=sse  -ftree-vectorizer-verbose=5 

    (Clang enables auto-vectorization at -O2. ICC defaults to optimization enabled + fast-math.)


    Most of the following was written by Peter Cordes, who could have just written a new answer. Over time, as compilers change, options and compiler output will change. I am not entirely sure whether it is worth tracking it in great detail here. Comments? — Author

    To also use instruction set extensions supported by the hardware you’re compiling on, and tune for it, use -march=native.

    Reduction loops (like sum of an array) will need OpenMP or -ffast-math to treat FP math as associative and vectorize. Example on the Godbolt compiler explorer with -O3 -march=native -ffast-math including a reduction (array sum) which is scalar without -ffast-math. (Well, GCC8 and later do a SIMD load and then unpack it to scalar elements, which is pointless vs. simple unrolling. The loop bottlenecks on the latency of the one addss dependency chain.)

    Sometimes you don’t need -ffast-math, just -fno-math-errno can help gcc inline math functions and vectorize something involving sqrt and/or rint / nearbyint.

    Other useful options include -flto (link-time optimization for cross-file inlining, constant propagation, etc) and / or profile-guided optimization with -fprofile-generate / test run(s) with realistic input(s) /-fprofile-use. PGO enables loop unrolling for ‘hot’ loops; in modern GCC that’s off by default even at -O3.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 106k
  • Answers 106k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You should use window.open('url to open','window name','toolbar=no'); May 11, 2026 at 8:51 pm
  • Editorial Team
    Editorial Team added an answer You can try LINQ 101 samples, they are pretty much… May 11, 2026 at 8:51 pm
  • Editorial Team
    Editorial Team added an answer Normally, callbacks in objective C are done with delegates. Here's… May 11, 2026 at 8:51 pm

Related Questions

Ok, I love Resharper and its addins, but even the best of fanbois have
I'm using EntLib v4 for Logging and currently I'm saving the events to the
Updated: The actual resolution that the compile box which served my compile request was
I'm using v4.0. Update: I've hacked together this so far: public class AllFilter :

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.