RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1150606 - summing bitfield generates invalid code(using sse2 in -O3)
Summary: summing bitfield generates invalid code(using sse2 in -O3)
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: gcc
Version: 6.5
Hardware: x86_64
OS: Linux
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Jakub Jelinek
QA Contact: Miroslav Franc
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-10-08 14:01 UTC by Rafal Wijata
Modified: 2016-02-01 02:29 UTC (History)
7 users (show)

Fixed In Version: gcc-4.4.7-12.el6
Doc Type: Bug Fix
Doc Text:
Previously, when the vectorization optimization was enabled, the compiler could extract a scalar component of a vector with element types whose precision did not match the precision of their mode. Consequently, GCC could terminate unexpectedly while trying to vectorize a code that was using bit-fields. With this update, the compiler no longer vectorizes such code and the code now compiles correctly.
Clone Of:
Environment:
Last Closed: 2015-07-22 06:48:26 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2015:1339 0 normal SHIPPED_LIVE gcc bug fix and enhancement update 2015-07-20 18:00:00 UTC

Description Rafal Wijata 2014-10-08 14:01:13 UTC
Description of problem:
iterating over vector/table of bitfield structs and summing generates wrong sum(using sse2 instructions in -O3).

Version-Release number of selected component (if applicable):
RHEL6.5 gcc-4.4.7-4.el6.x86_64
RHEL5 gcc44-4.4.7-1.el5

How reproducible:
#include <stdio.h>
#include <stdint.h>

struct Bitf
{
    uint64_t begin  : 40;
    uint64_t len : 24;
};// __attribute__((packed));

void main(int argc, char * argv[])
{

    struct Bitf bf[10];
    uint64_t i;
    for(i = 0; i < 10; ++i)
    {
       struct Bitf b1 = {(1ULL << 40)-1, i};
       bf[i] = b1;
    }

    uint64_t rv = 0;
    struct Bitf * it;
    for(it = bf; it != (bf + 10); ++it)
    {
        rv += it->len;
    }
    printf("%llu\n",  rv);
}

Steps to Reproduce:
1. /usr/bin/gcc -o a1 a1.c -O3 -m64
2. ./a1

Actual results:
34225520685

Expected results:
45

Additional info:
-m32 -msse2 is buggy as well

Comment 2 Rafal Wijata 2014-10-08 14:36:13 UTC
-fno-tree-vectorize works this problem around

Comment 3 Marek Polacek 2014-10-08 15:19:57 UTC
r157624 seems to fix it.

Comment 7 errata-xmlrpc 2015-07-22 06:48:26 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2015-1339.html


Note You need to log in before you can comment on or make changes to this bug.