This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix PR45869
- From: Richard Guenther <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 7 Oct 2010 15:22:57 +0200 (CEST)
- Subject: [PATCH] Fix PR45869
This allows vector shifts of pointers if they are mere permutations.
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.
Will apply a simplified version to the 4.5 branch.
Richard.
2010-10-07 Richard Guenther <rguenther@suse.de>
PR middle-end/45869
* tree-cfg.c (verify_gimple_assign_binary): Allow vector shifts
of pointers.
* gcc.dg/torture/pr45869.c: New testcase.
Index: gcc/tree-cfg.c
===================================================================
*** gcc/tree-cfg.c (revision 165098)
--- gcc/tree-cfg.c (working copy)
*************** verify_gimple_assign_binary (gimple stmt
*** 3422,3427 ****
--- 3515,3521 ----
{
if (TREE_CODE (rhs1_type) != VECTOR_TYPE
|| !(INTEGRAL_TYPE_P (TREE_TYPE (rhs1_type))
+ || POINTER_TYPE_P (TREE_TYPE (rhs1_type))
|| FIXED_POINT_TYPE_P (TREE_TYPE (rhs1_type))
|| SCALAR_FLOAT_TYPE_P (TREE_TYPE (rhs1_type)))
|| (!INTEGRAL_TYPE_P (rhs2_type)
*************** verify_gimple_assign_binary (gimple stmt
*** 3435,3443 ****
debug_generic_expr (rhs2_type);
return true;
}
! /* For shifting a vector of floating point components we
only allow shifting by a constant multiple of the element size. */
! if (SCALAR_FLOAT_TYPE_P (TREE_TYPE (rhs1_type))
&& (TREE_CODE (rhs2) != INTEGER_CST
|| !div_if_zero_remainder (EXACT_DIV_EXPR, rhs2,
TYPE_SIZE (TREE_TYPE (rhs1_type)))))
--- 3529,3537 ----
debug_generic_expr (rhs2_type);
return true;
}
! /* For shifting a vector of non-integral components we
only allow shifting by a constant multiple of the element size. */
! if (!INTEGRAL_TYPE_P (TREE_TYPE (rhs1_type))
&& (TREE_CODE (rhs2) != INTEGER_CST
|| !div_if_zero_remainder (EXACT_DIV_EXPR, rhs2,
TYPE_SIZE (TREE_TYPE (rhs1_type)))))
Index: gcc/testsuite/gcc.dg/torture/pr45869.c
===================================================================
*** gcc/testsuite/gcc.dg/torture/pr45869.c (revision 0)
--- gcc/testsuite/gcc.dg/torture/pr45869.c (revision 0)
***************
*** 0 ****
--- 1,15 ----
+ /* { dg-do compile } */
+
+ char *
+ foo (unsigned int count, void **list)
+ {
+ char *minaddr = (char *) list[0];
+ unsigned int i; /* NOTE: change of type to "int" eliminates the ICE */
+ for (i = 1; i < count; i++)
+ {
+ char *addr = (char *) list[i];
+ if (addr < minaddr)
+ minaddr = addr;
+ }
+ return minaddr;
+ }