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

  • SEARCH
  • Home
  • 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 8221773
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T14:02:55+00:00 2026-06-07T14:02:55+00:00

Reading this fascinating (and highest voted question) on SO, Why is it faster to

  • 0

Reading this fascinating (and highest voted question) on SO, Why is it faster to process a sorted array than an unsorted array? made me wonder about compiler code correctness.

For example, the answer states that:

Intel Compiler 11 does something miraculous. It interchanges the two loops…

How does a compiler programmer know when it’s OK to interchange loops?

And, in general, do they use mathematical proofs to demonstrate conclusions?

How does a compiler programmer know that their compiler will generate correct code? How do they test their conclusion? Do they have to write a test suite that runs the compiler, and checks that the generated code is correct?

  • 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. Editorial Team
    Editorial Team
    2026-06-07T14:02:56+00:00Added an answer on June 7, 2026 at 2:02 pm

    How does a compiler programmer know when it’s OK to interchange loops?

    The compiler runs a series of checks on the code to determine if it’s safe to interchange loops. For example, if the code doesn’t fully inline, it probably won’t be able to interchange the loops. If the code modifies a volatile variable, it won’t interchange the loops. If the code stores values that are computed in previous loop iterations, the compiler won’t interchange the loops. If they can be sure it’s safe because none of these conditions are triggered, the compile can interchange the loops.

    And, in general, do they use mathematical proofs to demonstrate conclusions?

    No. They just work out an optimization and a set of conservative tests to ensure that optimizations is safe. Over time, they develop more optimizations and more sophisticated algorithms to detect when the optimization is safe even in cases where it’s less obvious.

    How does a compiler programmer know that their compiler will generate correct code?

    They do the best they can. Occasionally they make mistakes. People submit bug reports, and they fix it.

    How do they test their conclusion? Do they have to write a test suite that runs the compiler, and checks that the generated code is correct?

    They absolutely do use test suites. When a bug is detected in GCC, a test is specifically added to the test suite to make sure that bug is fixed and not re-introduced.

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

Sidebar

Related Questions

After reading this SO question and noting the consensus about just how evil Thread.Sleep()
When reading this question I started to wonder a bit. Say you have these
After reading this question here: Passing one Dimension of a Two Dimensional Array in
Reading this blog post about HttpOnly cookies made me start thinking, is it possible
Afer reading this topic C++ interview preparation (Matt's answer) I've got a question about
Reading this article http://support.microsoft.com/kb/813878 I have a question: Where can I get ipseccmd.exe for
After reading this question, I need to clear up some things. IQueryable<Customer> custs =
After reading this question , i saw the answer by Naveen containing a link
Reading this question got me thinking: For a given function f , how can
After reading this question I attempted to clean out my workspace and found that

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.