Author: pallavimathew
Date: 2011-04-25 19:15:52 -0400 (Mon, 25 Apr 2011)
New Revision: 3571

Modified:
   trunk/osprey/be/opt/opt_revise_ssa.cxx
Log:
This change is to preserve the alignment when folding indirect load/store.

When folding indirect load/store, say "load from or store to *(&a_vector)", 
the compiler replaced the expression into "load from or store to a_vector".
In the meantime, it blindly set the alignment to 16. This caused segmentation 
fault if :
  o. the array access being vectorized is a field of (FORTRAN 95's) structure, 
and
  o. the array is not laid out at 16-byte boundary.

Approved by Sun Chan.


Modified: trunk/osprey/be/opt/opt_revise_ssa.cxx
===================================================================
--- trunk/osprey/be/opt/opt_revise_ssa.cxx      2011-04-25 21:05:49 UTC (rev 
3570)
+++ trunk/osprey/be/opt/opt_revise_ssa.cxx      2011-04-25 23:15:52 UTC (rev 
3571)
@@ -148,6 +148,12 @@
   OPT_REVISE_SSA(const OPT_REVISE_SSA&); // REQUIRED UNDEFINED UNWANTED methods
   OPT_REVISE_SSA& operator = (const OPT_REVISE_SSA&); // REQUIRED UNDEFINED 
UNWANTED methods
 
+  TY_IDX Compose_TY_IDX (TY_IDX idx_part, TY_IDX subty_part) {
+    TY_IDX new_ty = subty_part;
+    Set_TY_IDX_index (new_ty, TY_IDX_index (idx_part));
+    return new_ty;  
+  }
+
 public:
   OPT_REVISE_SSA( OPT_STAB *opt_stab, CODEMAP *htable, CFG *cfg, MEM_POOL 
*lpool, INT trace_flag): 
        _opt_stab(opt_stab), _htable(htable), _cfg(cfg), _loc_pool(lpool) {
@@ -1331,6 +1337,8 @@
   CODEREP *new_cr = Alloc_stack_cr(cr->Extra_ptrs_used());
   BOOL need_rehash;
   INT32 i;
+  TY_IDX orig_ld_ty;
+
   switch (cr->Kind()) {
   case CK_CONST:
   case CK_RCONST:
@@ -1338,6 +1346,7 @@
   case CK_VAR:
     return NULL;
   case CK_IVAR:
+    orig_ld_ty = cr->Ilod_ty ();
     x = Fold_lda_iloads(cr->Ilod_base());
     if (x)
       cr->Set_ilod_base(x);
@@ -1392,7 +1401,8 @@
     x->Set_field_id(cr->I_field_id());
     if (x->Field_id() == 0 && x->Dsctyp() != MTYPE_M && 
        TY_size(x->Lod_ty()) != MTYPE_byte_size(x->Dsctyp()))
-      x->Set_lod_ty(MTYPE_To_TY(x->Dsctyp()));
+      x->Set_lod_ty(Compose_TY_IDX (MTYPE_To_TY(x->Dsctyp()), orig_ld_ty));
+
     if (cr->Dsctyp() == MTYPE_BS) // cannot use offset from opt_stab
       x->Set_offset(cr->Offset()+cr->Ilod_base()->Offset());
     if (cr->Opr() == OPR_ILDBITS) 
@@ -1487,6 +1497,8 @@
       }
 
       if (OPERATOR_is_store(opr)) {
+        TY_IDX orig_ty;
+
        CODEREP *lhs = stmt->Lhs();
        AUX_ID vaux;
         switch (opr) {
@@ -1500,6 +1512,7 @@
          break;
         case OPR_ISTORE:
         case OPR_ISTBITS:
+         orig_ty = lhs->Ilod_ty ();
          if (lhs->Istr_base()->Kind() != CK_LDA) {
            x = Fold_lda_iloads(lhs->Istr_base());
            if (x)
@@ -1524,8 +1537,11 @@
                        TY_pointed(lhs->Ilod_base_ty()), lhs->I_field_id(), 
                        TRUE));
          if (stmt->Lhs()->Field_id() == 0 && stmt->Lhs()->Dsctyp() != MTYPE_M 
&& 
-             TY_size(stmt->Lhs()->Lod_ty()) != 
MTYPE_byte_size(stmt->Lhs()->Dsctyp()))
-           stmt->Lhs()->Set_lod_ty(MTYPE_To_TY(stmt->Lhs()->Dsctyp()));
+             TY_size(stmt->Lhs()->Lod_ty()) != 
MTYPE_byte_size(stmt->Lhs()->Dsctyp())) {
+           TY_IDX new_ty =
+             Compose_TY_IDX (MTYPE_To_TY(stmt->Lhs()->Dsctyp()), orig_ty);
+           stmt->Lhs()->Set_lod_ty (new_ty);
+         }
          if (lhs->Dsctyp() == MTYPE_BS) // cannot use offset from opt_stab
            stmt->Lhs()->Set_offset(lhs->Offset()+lhs->Istr_base()->Offset());
          if (stmt->Opr() == OPR_ISTORE)


------------------------------------------------------------------------------
WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network 
management toolset available today.  Delivers lowest initial 
acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd
_______________________________________________
Open64-devel mailing list
Open64-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/open64-devel

Reply via email to