Bug 34050

Summary: optimizing bug in GCSE
Product: [Retired] Red Hat Linux Reporter: Michael Stefaniuc <mstefani>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED RAWHIDE QA Contact: David Lawrence <dkl>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.0CC: jamesjuran
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2001-03-30 11:16:24 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Description Michael Stefaniuc 2001-03-30 10:59:38 UTC
gcc produces with -O2 incorrect code, culprit *appears* to be the global
common subexpression elimination. Correct code is produced with -O2
-fno-gcse
Bug is also present in gcc-2.96-80 .

Credits: - Francois Jacques for founding the bug
	 - Ulrich Weigand for the test case


Test case:

void clobber(int *);
void compare(int, int);
void use(int);

int global;

void test(int trigger, int param)
{
    int data = trigger? global : 0;
    int orig_param = param;
    
    clobber(&param);
    compare(orig_param, param);

    use(data);
}

void clobber(int *param)
{
    (*param)++;
}

void compare(int orig_param, int param)
{
    if (orig_param != param)
        printf( "PASS\n" );
    else
        printf( "FAIL\n" );
}

void use(int data)
{
}

int main(void)
{
    test(0, 0);
}

Comment 1 Jakub Jelinek 2001-03-30 11:16:21 UTC
*** Bug 34051 has been marked as a duplicate of this bug. ***

Comment 2 Jakub Jelinek 2001-04-09 11:53:24 UTC
Fixed in gcc-2.96-81.