This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

fix incorrect SRA transformation on non-integral VIEW_CONVERT argument


Hello,

For the  "PA(1).Z := 44;" assignment in the attached Ada
testcase, we observe the gcc 4.5 SRA pass performing an
invalid transformation, turning:

  struct {
    system__pack_48__bits_48 OBJ;
  } D.1432;

  D.1432.OBJ = D.1435;
  T1b.F = VIEW_CONVERT_EXPR<struct pt__point>(D.1432);

into:

  SR.12_17 = D.1435_3;
  T1b.F = VIEW_CONVERT_EXPR<struct pt__point>(SR.12_17);

where we have

    <var_decl D.1432
     type <record_type 0x7ffff7fb72a0 BLK
        size <integer_cst 0x7ffff7fac960 constant 48>

and
 
    <var_decl SR.12
     type <integer_type system__pack_48__bits_48
        size <integer_cst 0x7ffff7ecd870 64>

        type <integer_type system__pack_48__bits_48___UMT
            size <integer_cst 64>

At least the change in size is problematic because the conversion
outcome might differ after the replacement, in particular on
big-endian targets.

mainline does something slightly different with the same effects
eventually (same testcase failure on sparc-solaris). The attached patch
is a proposal to address this at the point where we already check
for VCE in the access creation process, disqualifying scalarization
for a VCE argument of non-integral size.

We (AdaCore) have been using this internally for a while now.
I also checked that it fixes the observable problem on sparc, then
bootstrapped and regtested on i686-suse-linux.

OK to commit ?

Thanks in advance for your feedback,

Olivier

2012-04-25  Olivier Hainque  <hainque@adacore.com>

        * tree-sra.c (create_access): Additional IN_VCE argument, telling
        if EXPR is VIEW_CONVERT_EXPR input.  Disqualify base if access size
        is not that of an integer mode in this case.
        (build_access_from_expr_1): Adjust caller.

	testsuite/
	* gnat.dg/sra_vce[_decls].adb: New testcase.

Attachment: sravce.dif
Description: video/dv


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]