User account creation filtered due to spam.

Bug 10286 - [3.2.1 regression] [x86] type-punning doesn't work with __m64 and -O
Summary: [3.2.1 regression] [x86] type-punning doesn't work with __m64 and -O
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 3.2.2
: P3 normal
Target Milestone: ---
Assignee: Eric Botcazou
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-04-01 17:36 UTC by mgw
Modified: 2003-07-25 17:33 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
set64.i (7.60 KB, text/x-c)
2003-05-21 15:17 UTC, mgw
Details

Note You need to log in before you can comment on or make changes to this bug.
Description mgw 2003-04-01 17:36:00 UTC
the following program (.i attached) prints:

44 33 22 11 00 00 00 00 44 33 22 11 00 00 00 00 44 33 22 11 00 00 00 00 

instead of the expected:

88 77 66 55 44 33 22 11 88 77 66 55 44 33 22 11 88 77 66 55 44 33 22 11 

the generated assembly uses a movd to fill in %mm0, leaving the upper 32-bits empty.

// gcc -O -mmmx -o set64 set64.c
#include <mmintrin.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>

void
memset64(void *dst, uint32_t hi, uint32_t lo, size_t count)
{
        __m64 *p = (__m64 *)dst;
        __m64 fill = _mm_set_pi32(hi, lo);

        while (count--) {
                *p++ = fill;
        }
}

#define NUM 3 
int
main()
{
        uint8_t *buf = (uint8_t *)calloc(NUM * 2, sizeof(uint32_t));
        int i, count = NUM * 2 * sizeof(uint32_t);

        memset64(buf, 0x11223344, 0x55667788, NUM);
        for (i = 0; i < count; i++) {
                printf("%02x ", buf[i]);
        }
        printf("\n");
        return 0;
}

Release:
gcc-3.2.2

Environment:
Mandrake Linux 9.1.1

How-To-Repeat:
run attached program built with -O -mmmx
Comment 1 Eric Botcazou 2003-04-10 07:26:46 UTC
State-Changed-From-To: open->analyzed
State-Changed-Why: Confirmed on 3.2 branch. 3.3 and mainline are not affected.
Comment 2 Eric Botcazou 2003-04-10 08:29:21 UTC
Responsible-Changed-From-To: unassigned->ebotcazou
Responsible-Changed-Why: Investigating.
Comment 3 Joe Buck 2003-04-25 21:51:55 UTC
State-Changed-From-To: analyzed->closed
State-Changed-Why: Fixed for 3.3.