Permute conversion and addition of constant for zero-extend.
authorH.J. Lu <hongjiu.lu@intel.com>
Fri, 19 Aug 2011 21:18:03 +0000 (21:18 +0000)
committerH.J. Lu <hjl@gcc.gnu.org>
Fri, 19 Aug 2011 21:18:03 +0000 (14:18 -0700)
gcc/

2011-08-19  H.J. Lu  <hongjiu.lu@intel.com>

PR middle-end/49721
* explow.c (convert_memory_address_addr_space): Also permute the
conversion and addition of constant for zero-extend.

gcc/testsuite/

2011-08-19  H.J. Lu  <hongjiu.lu@intel.com>

PR middle-end/49721
* gfortran.dg/pr49721-1.f: New.
* gfortran.fortran-torture/compile/pr49721-1.f: Likewise.

From-SVN: r177914

gcc/ChangeLog
gcc/explow.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/pr49721-1.f [new file with mode: 0644]
gcc/testsuite/gfortran.fortran-torture/compile/pr49721-1.f [new file with mode: 0644]

index 99986b588d1ef0d27b94ef25541c190bf1c04be7..b94e583b80b148e525e89ead51ffd25348932139 100644 (file)
@@ -1,3 +1,9 @@
+2011-08-19  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR middle-end/49721
+       * explow.c (convert_memory_address_addr_space): Also permute the
+       conversion and addition of constant for zero-extend.
+
 2011-08-19  Joseph Myers  <joseph@codesourcery.com>
 
        * c-parser.c (c_parser_postfix_expression): Handle
index beeab44e8ac47e53c6fd4e098ecf31da82db1362..984150efd05ab5428fe97897f3a30f0178f004e0 100644 (file)
@@ -384,18 +384,23 @@ convert_memory_address_addr_space (enum machine_mode to_mode ATTRIBUTE_UNUSED,
 
     case PLUS:
     case MULT:
-      /* For addition we can safely permute the conversion and addition
-        operation if one operand is a constant and converting the constant
-        does not change it or if one operand is a constant and we are
-        using a ptr_extend instruction  (POINTERS_EXTEND_UNSIGNED < 0).
+      /* FIXME: For addition, we used to permute the conversion and
+        addition operation only if one operand is a constant and
+        converting the constant does not change it or if one operand
+        is a constant and we are using a ptr_extend instruction
+        (POINTERS_EXTEND_UNSIGNED < 0) even if the resulting address
+        may overflow/underflow.  We relax the condition to include
+        zero-extend (POINTERS_EXTEND_UNSIGNED > 0) since the other
+        parts of the compiler depend on it.  See PR 49721.
+
         We can always safely permute them if we are making the address
         narrower.  */
       if (GET_MODE_SIZE (to_mode) < GET_MODE_SIZE (from_mode)
          || (GET_CODE (x) == PLUS
              && CONST_INT_P (XEXP (x, 1))
-             && (XEXP (x, 1) == convert_memory_address_addr_space
-                                  (to_mode, XEXP (x, 1), as)
-                 || POINTERS_EXTEND_UNSIGNED < 0)))
+             && (POINTERS_EXTEND_UNSIGNED != 0
+                 || XEXP (x, 1) == convert_memory_address_addr_space
+                                       (to_mode, XEXP (x, 1), as))))
        return gen_rtx_fmt_ee (GET_CODE (x), to_mode,
                               convert_memory_address_addr_space
                                 (to_mode, XEXP (x, 0), as),
index 50a971129a546d3907cfab0b329c0f0791d44818..b3ee4b34746c68eeeb643b396cc655b78957809c 100644 (file)
@@ -1,3 +1,9 @@
+2011-08-19  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR middle-end/49721
+       * gfortran.dg/pr49721-1.f: New.
+       * gfortran.fortran-torture/compile/pr49721-1.f: Likewise.
+
 2011-08-19  Joseph Myers  <joseph@codesourcery.com>
 
        * gcc.dg/builtin-complex-err-1.c, gcc.dg/builtin-complex-err-2.c,
diff --git a/gcc/testsuite/gfortran.dg/pr49721-1.f b/gcc/testsuite/gfortran.dg/pr49721-1.f
new file mode 100644 (file)
index 0000000..39e2ed7
--- /dev/null
@@ -0,0 +1,35 @@
+! PR middle-end/49721
+! { dg-do compile }
+! { dg-options "-O3 -funroll-loops" }
+
+      subroutine midbloc6(c,a2,a2i,q)
+      parameter (ndim2=6)
+      parameter (ndim=3)
+      dimension ri(ndim2),cr(ndim2,ndim2),xj(ndim2,ndim2),q(*)
+     @,sai(ndim2,ndim2),cm(ndim2,ndim2),w(ndim2,ndim2)
+      dimension vr(ndim2,ndim2),vi(ndim2,ndim2),s1(ndim2,ndim2),p(ndim)
+      dimension xq(6),qb(2),qc(2),ifl(6),iplane(3)
+      save
+      call eig66(cr,rr,ri,vr,vi)
+      xq(i)=asin(ri(i))/x2pi
+      i9=6
+      qb(1)=q(1)/x2pi
+        do 180 i=1,2
+          do 170 j=1,6
+  120       if(xq(j)) 130,190,140
+  130       if(qb(i)-0.5d0) 160,150,150
+  140       if(qb(i)-0.5d0) 150,150,160
+  150       continue
+            tst=abs(abs(qb(i))-abs(xq(j)))
+  160       continue
+  170     continue
+          iplane(i)=k
+  180   continue
+  190   continue
+      n1=iplane(3)
+      if(i9.eq.6) then
+        z=vr(1,n1)*vi(2,n1)-vr(2,n1)*vi(1,n1)+vr(3,n1)*vi(4,n1)-vr(4,n1)
+      endif
+      sai(6,i)=vi(i,n1)/z
+      call dacond6(a2,zero)
+      end
diff --git a/gcc/testsuite/gfortran.fortran-torture/compile/pr49721-1.f b/gcc/testsuite/gfortran.fortran-torture/compile/pr49721-1.f
new file mode 100644 (file)
index 0000000..9ddd068
--- /dev/null
@@ -0,0 +1,9 @@
+       PARAMETER( LM=7 )
+      PARAMETER( NM=2+2**LM, NV=NM**3 )
+      PARAMETER( NR = (8*(NM**3+NM**2+5*NM-23+7*LM))/7 )
+       COMMON /X/ U, V, R, A
+      REAL*8 U(NR),V(NV),R(NR),A(0:3)
+      DO 20 IT=1,NIT
+        CALL RESID(U,V,R,N,A)
+ 20   CONTINUE
+      END