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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:31:33+00:00 2026-06-17T11:31:33+00:00

I’ve been scratching my head over this one for some time. I’m using GCC

  • 0

I’ve been scratching my head over this one for some time. I’m using GCC 4.4.4 (I have checked GCCs 3.4.6, 4.4.6, and 4.6.3.) and ran into an issue in some math I was doing. I boiled the example into the following self-contained program:

#include <stdio.h>
int main()
{
    float something[4] = { 1.0f, 2.0f, 3.0f, 4.0f };
    asm volatile
    (
        "movups %0, %%xmm0 \n\t"
        "movups %%xmm0, %0 \n\t"
        : "=m" (*something)
        :
        : "memory", "xmm0"
    );
    printf("%.0f %.0f %.0f %.0f\n",
        something[0], something[1], something[2], something[3]);
    return 0;
}

Compiled simply with

gcc -msse -O -o something something.c

it fails by somehow corrupting the first array element (except on the GCC 3.4.6 I tried … there, it works fine). I can’t, for the life of me, see anything fundamentally wrong here.

If I, instead, change the ASM block in question to

_mm_storeu_ps(something, _mm_loadu_ps(something));

it works fine. I checked the generated assembly code and found that the version with the ASM block contained one less store operation leading up to the SSE part:

main:
    pushl   %ebp
    movl    %esp, %ebp
    andl    $-16, %esp
    subl    $64, %esp
    movl    $0x40000000, 52(%esp)
    movl    $0x40400000, 56(%esp)
    movl    $0x40800000, 60(%esp)

versus the more correct (code using intrinsics):

main:
    pushl   %ebp
    movl    %esp, %ebp
    andl    $-16, %esp
    subl    $64, %esp
    movl    $0x3f800000, 48(%esp)
    movl    $0x40000000, 52(%esp)
    movl    $0x40400000, 56(%esp)
    movl    $0x40800000, 60(%esp)

WTF is wrong with either me or GCC?

(Note, this is a boiled-down, concise example showing the root problem I’ve tracked down. There are reasons for the ASM block and the volatile keyword all of which don’t really seem to address the main concern I’m putting forward here.)

  • 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-17T11:31:34+00:00Added an answer on June 17, 2026 at 11:31 am

    You used wrong constraint (incidentally this is the second such problem asked here today).
    The = means output, so gcc thought you were going to assign *something which is the first array element. So it figured it can omit the initialization since you will overwrite it anyway. You should use + sign to mark an operand as input-output, like so: "+m" (*something).

    "=m" (something) in general means you will assign to the pointer, as such gcc could decide to omit all the initialization. Note that for arrays this shouldn’t even compile, just like the equivalent C code doesn’t. It’s just a lucky accident (aka. compiler bug) that it compiles and even works.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a jquery bug and I've been looking for hours now, I can't
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
This could be a duplicate question, but I have no idea what search terms
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have been unable to fix a problem with Java Unicode and encoding. The

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.