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 7647737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:32:15+00:00 2026-05-31T10:32:15+00:00

At the GoingNative event, during the Interactive Panel on Day2 at the 9 minute

  • 0

At the GoingNative event, during the Interactive Panel on Day2 at the 9 minute mark, Chandler Carruth says:

Pointers create aliasing problems. They slow down your binaries not speed them up.

What does this mean? Can this be illustrated with a (simple) example?

  • 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-05-31T10:32:16+00:00Added an answer on May 31, 2026 at 10:32 am

    Aliasing affects performance by preventing the compiler from doing certain optimizations. For example:

    void foo(int *array,int *size,int *value) {
        for(int i=0;i<*size;++i) {
            array[i] = 2 * *value;
        }
    }
    

    Looking at this code you might expect that the compiler could load *value once outside the loop and then set every element in the array to that value very quickly. But this isn’t the case due to aliasing. Because *value could be an alias for an element of the array it could change on any given iteration. Therefore the code has to load the value every single iteration, resulting in a potentially large slowdown.

    If the variables could not alias then the above code would be equivalent to the following:

    void foo(int *array,int size,int value) {
        for(int i=0;i<size;++i) {
            array[i] = 2 * value;
        }
    }
    

    Using LLVM’s online demo to get the generated code, here are the different results:

    1) With aliasing

    foo:                                    # @foo
        .cfi_startproc
    # BB#0:
        cmpl    $0, (%rsi)
        jle .LBB0_3
    # BB#1:
        xorl    %eax, %eax
        .align  16, 0x90
    .LBB0_2:                                # %.lr.ph
                                            # =>This Inner Loop Header: Depth=1
        movl    (%rdx), %ecx
        addl    %ecx, %ecx
        movl    %ecx, (%rdi,%rax,4)
        incq    %rax
        cmpl    (%rsi), %eax
        jl  .LBB0_2
    .LBB0_3:                                # %._crit_edge
        ret
        .size   foo, .Ltmp1-foo
        .cfi_endproc
    .Leh_func_end0:
    

    2) Without aliasing

    foo:                                    # @foo
        .cfi_startproc
    # BB#0:
        testl   %esi, %esi
        jle .LBB0_3
    # BB#1:                                 # %.lr.ph
        addl    %edx, %edx
        .align  16, 0x90
    .LBB0_2:                                # =>This Inner Loop Header: Depth=1
        movl    %edx, (%rdi)
        addq    $4, %rdi
        decl    %esi
        jne .LBB0_2
    .LBB0_3:                                # %._crit_edge
        ret
        .size   foo, .Ltmp1-foo
        .cfi_endproc
    .Leh_func_end0:
    

    You can see that the version with aliasing has to do more work in the loop body (between the labels LBB0_2 and LBB0_3).

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

Sidebar

Related Questions

In Andrei's talk on GoingNative 2012 he talks about Variadic Templates, and he explains
Possible Duplicate: Garbage Collection in C++ — why? At Going Native 2012 today during
I would like to create a zip file from files located on the sd
I have built a web-app for iphone using iUi framework. As you may already
I have been trying to find a way to get Clang working on Windows
I am a reasonably competent C# developer who has experience in threading, web development,
I am trying to read unicode string from a console in C#, for the
I have problem where google chrome is showing: The site uses SSL, but Google
I'm about to write a piece of software for my MSc project in C++

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.