[PATCH][4.3] Fix PR36187, wrong partitioning with SFTs and unions
Richard Guenther
rguenther@suse.de
Fri May 9 14:56:00 GMT 2008
With the testcase in this PR we forget to mark unpartitionable SFTs as
such if going through the special case for unions in set_uids_in_ptset.
Fixed with the following patch, bootstrap & regtest on
x86_64-unknown-linxu-gnu in progress. I'll apply this to the branch
after it succeeded.
Thanks,
Richard.
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/pr36187.C: New testcase.
Index: gcc/tree-dfa.c
===================================================================
*** gcc/tree-dfa.c (revision 135071)
--- gcc/tree-dfa.c (working copy)
*************** dump_variable (FILE *file, tree var)
*** 426,432 ****
fprintf (file, ", offset: " HOST_WIDE_INT_PRINT_UNSIGNED,
SFT_OFFSET (var));
fprintf (file, ", base for components: %s",
! SFT_BASE_FOR_COMPONENTS_P (var) ? "NO" : "YES");
fprintf (file, ", partitionable: %s",
SFT_UNPARTITIONABLE_P (var) ? "NO" : "YES");
}
--- 426,432 ----
fprintf (file, ", offset: " HOST_WIDE_INT_PRINT_UNSIGNED,
SFT_OFFSET (var));
fprintf (file, ", base for components: %s",
! SFT_BASE_FOR_COMPONENTS_P (var) ? "YES" : "NO");
fprintf (file, ", partitionable: %s",
SFT_UNPARTITIONABLE_P (var) ? "NO" : "YES");
}
Index: gcc/tree-ssa-structalias.c
===================================================================
*** gcc/tree-ssa-structalias.c (revision 135072)
--- gcc/tree-ssa-structalias.c (working copy)
*************** set_uids_in_ptset (tree ptr, bitmap into
*** 4757,4763 ****
/* Variables containing unions may need to be converted to
their SFT's, because SFT's can have unions and we cannot. */
for (i = 0; VEC_iterate (tree, sv, i, subvar); ++i)
! bitmap_set_bit (into, DECL_UID (subvar));
}
else if (TREE_CODE (vi->decl) == VAR_DECL
|| TREE_CODE (vi->decl) == PARM_DECL
--- 4757,4775 ----
/* Variables containing unions may need to be converted to
their SFT's, because SFT's can have unions and we cannot. */
for (i = 0; VEC_iterate (tree, sv, i, subvar); ++i)
! {
! /* Pointed-to SFTs are needed by the operand scanner
! to adjust offsets when adding operands to memory
! expressions that dereference PTR. This means
! that memory partitioning may not partition
! this SFT because the operand scanner will not
! be able to find the other SFTs next to this
! one. But we only need to do this if the pointed
! to type is aggregate. */
! if (SFT_BASE_FOR_COMPONENTS_P (subvar))
! SFT_UNPARTITIONABLE_P (subvar) = true;
! bitmap_set_bit (into, DECL_UID (subvar));
! }
}
else if (TREE_CODE (vi->decl) == VAR_DECL
|| TREE_CODE (vi->decl) == PARM_DECL
Index: gcc/testsuite/g++.dg/pr36187.C
===================================================================
*** gcc/testsuite/g++.dg/pr36187.C (revision 0)
--- gcc/testsuite/g++.dg/pr36187.C (revision 0)
***************
*** 0 ****
--- 1,45 ----
+ /* { dg-do run } */
+ /* { dg-options "-O2 --param max-aliased-vops=20" } */
+
+ 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;
+ }
More information about the Gcc-patches
mailing list