Bug 36187 - [4.3 Regression] Partitioning problem with SFTs (again)
Summary: [4.3 Regression] Partitioning problem with SFTs (again)
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.3.1
: P3 normal
Target Milestone: 4.3.1
Assignee: Richard Biener
URL:
Keywords: alias, wrong-code
Depends on:
Blocks:
 
Reported: 2008-05-09 13:26 UTC by Richard Biener
Modified: 2008-05-09 19:20 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work: 4.2.3 4.3.1 4.4.0
Known to fail: 4.3.0
Last reconfirmed: 2008-05-09 14:21:11


Attachments
testcase (1.48 KB, text/plain)
2008-05-09 13:26 UTC, Richard Biener
Details
more minimized testcase (924 bytes, text/plain)
2008-05-09 13:56 UTC, Richard Biener
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Biener 2008-05-09 13:26:20 UTC
A similar problem as PR33870 is still present as seen with the attached testcase
(forwarded from https://bugzilla.novell.com/show_bug.cgi?id=388664):

g++-4.3 -O2 -o t testfoo.cxx
./t
start test
dbl2 data error 0x0
dbl2 data error 0x4002, value n was 1.000000
fail e.g. interesting

g++-4.3 -O2 -o t testfoo.cxx --param max-aliased-vops=600
./t
start test
end test
Comment 1 Richard Biener 2008-05-09 13:26:44 UTC
Created attachment 15619 [details]
testcase
Comment 2 Richard Biener 2008-05-09 13:29:46 UTC
The symptom of the alias problem is that we apply store-motion to

        aTmp.eType = SbxDataType( p->eType | SbxBYREF );

but reads through

        p = &aTmp; goto start;

in that stmt incorrectly do not alias that store.
Comment 3 Richard Biener 2008-05-09 13:56:21 UTC
Created attachment 15621 [details]
more minimized testcase
Comment 4 Richard Biener 2008-05-09 14:09:41 UTC
The following aborts with -O2 --param max-aliased-vops=N with N in [19, 25]
on x86_64-unknown-linux-gnu.  Symptom is still lim being wrongly applied.
If you cannot reproduce it search for the correct N with

for n in `seq 0 5 100`; do g++-4.3 -O2 -S testfoo.cxx -fdump-tree-lim -B/abuild/rguenther/gcc43-g/gcc --param max-aliased-vops=$n; grep lsm testfoo.cxx.095t.lim > /dev/null 2>&1 && echo $n; done

extern "C" void abort (void);
enum SbxDataType { SbxINTEGER, SbxDECIMAL, SbxBYREF = 0x4000 };
struct SbxValues {
    union {
        float nSingle;
        float* pSingle;
    };
    SbxDataType eType;
};
static bool ImpPutDoubleFoo( SbxValues* p)
{
    bool bRet = false;
    SbxValues aTmp;
    int count = 0;
start:
    switch( p->eType )  {
        case SbxINTEGER:
            if (count++ > 0)
              abort ();
            aTmp.pSingle = &p->nSingle; goto direct;
        case SbxBYREF | SbxDECIMAL:
            bRet = false;
            break;
        direct:
            aTmp.eType = SbxDataType( p->eType | SbxBYREF );
            p = &aTmp; goto start;
        case SbxBYREF | SbxINTEGER:
            break;
        default:
            bRet =true;
    }
    return bRet;
}
int main( int argc, char** argv )
{
    SbxValues aTmp;
    aTmp.eType = SbxINTEGER;
    if ( ImpPutDoubleFoo( &aTmp ) )
        abort ();
    return 0;
}
Comment 5 Richard Biener 2008-05-09 14:26:15 UTC
We don't properly mark all fields of the union as base_for_components.  But
the real problem is probably that field-sensitive PTA doesn't consider
structs with unions but we still create SFTs for them.  If we didn't do that
the problem with base_for_components would be avoided as well.
Comment 6 Richard Biener 2008-05-09 19:20:18 UTC
Subject: Bug 36187

Author: rguenth
Date: Fri May  9 19:19:33 2008
New Revision: 135125

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=135125
Log:
2008-05-09  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/36187
	* tree-dfa.c (dump_variable): Correct dumping of
	SFT_BASE_FOR_COMPONENTS_P.
	* tree-ssa-structalias.c (set_uids_in_ptset): Set
	SFT_UNPARTITIONABLE_P correctly for the union case.

	* g++.dg/opt/pr36187.C: New testcase.

Added:
    branches/gcc-4_3-branch/gcc/testsuite/g++.dg/opt/pr36187.C
Modified:
    branches/gcc-4_3-branch/gcc/ChangeLog
    branches/gcc-4_3-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_3-branch/gcc/tree-dfa.c
    branches/gcc-4_3-branch/gcc/tree-ssa-structalias.c

Comment 7 Richard Biener 2008-05-09 19:20:51 UTC
Fixed.
Comment 8 Richard Biener 2008-05-09 20:05:41 UTC
Subject: Bug 36187

Author: rguenth
Date: Fri May  9 20:04:57 2008
New Revision: 135126

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=135126
Log:
2008-05-09  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/36187
	* g++.dg/opt/pr36187.C: New testcase.

Added:
    trunk/gcc/testsuite/g++.dg/opt/pr36187.C
      - copied unchanged from r135125, branches/gcc-4_3-branch/gcc/testsuite/g++.dg/opt/pr36187.C
Modified:
    trunk/gcc/testsuite/ChangeLog