aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2014-04-28 14:36:13 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2014-04-28 14:36:13 +0000
commit22869a37b0d0bb3107a6a55d95a08dd243bc50fc (patch)
tree51d32838b9998a12218d4e27734aff397aed9cb6 /gcc
parent771c950116f7b08a45eecb6334954cfe8891a587 (diff)
downloadgcc-22869a37b0d0bb3107a6a55d95a08dd243bc50fc.zip
gcc-22869a37b0d0bb3107a6a55d95a08dd243bc50fc.tar.gz
gcc-22869a37b0d0bb3107a6a55d95a08dd243bc50fc.tar.bz2
re PR middle-end/60092 (posix_memalign not recognized to derive alias and alignment info)
2014-04-28 Richard Biener <rguenther@suse.de> PR middle-end/60092 * builtins.def (DEF_C11_BUILTIN): Add. (BUILT_IN_ALIGNED_ALLOC): Likewise. * coretypes.h (enum function_class): Add function_c11_misc. * tree-ssa-alias.c (ref_maybe_used_by_call_p_1): Handle BUILT_IN_ALIGNED_ALLOC like BUILT_IN_MALLOC. (call_may_clobber_ref_p_1): Likewise. * tree-ssa-dce.c (mark_stmt_if_obviously_necessary): Likewise. (mark_all_reaching_defs_necessary_1): Likewise. (propagate_necessity): Likewise. (eliminate_unnecessary_stmts): Likewise. * tree-ssa-ccp.c (evaluate_stmt): Handle BUILT_IN_ALIGNED_ALLOC. ada/ * gcc-interface/utils.c: Define flag_isoc11. lto/ * lto-lang.c: Define flag_isoc11. * gcc.dg/tree-ssa/alias-32.c: New testcase. * gcc.dg/vect/pr60092.c: Likewise. From-SVN: r209863
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog15
-rw-r--r--gcc/ada/ChangeLog5
-rw-r--r--gcc/ada/gcc-interface/utils.c1
-rw-r--r--gcc/builtins.def8
-rw-r--r--gcc/coretypes.h3
-rw-r--r--gcc/lto/ChangeLog5
-rw-r--r--gcc/lto/lto-lang.c1
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/alias-32.c20
-rw-r--r--gcc/testsuite/gcc.dg/vect/pr60092.c18
-rw-r--r--gcc/tree-ssa-alias.c2
-rw-r--r--gcc/tree-ssa-ccp.c19
-rw-r--r--gcc/tree-ssa-dce.c9
13 files changed, 109 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 67a4645..5e9a129 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,20 @@
2014-04-28 Richard Biener <rguenther@suse.de>
+ PR middle-end/60092
+ * builtins.def (DEF_C11_BUILTIN): Add.
+ (BUILT_IN_ALIGNED_ALLOC): Likewise.
+ * coretypes.h (enum function_class): Add function_c11_misc.
+ * tree-ssa-alias.c (ref_maybe_used_by_call_p_1): Handle
+ BUILT_IN_ALIGNED_ALLOC like BUILT_IN_MALLOC.
+ (call_may_clobber_ref_p_1): Likewise.
+ * tree-ssa-dce.c (mark_stmt_if_obviously_necessary): Likewise.
+ (mark_all_reaching_defs_necessary_1): Likewise.
+ (propagate_necessity): Likewise.
+ (eliminate_unnecessary_stmts): Likewise.
+ * tree-ssa-ccp.c (evaluate_stmt): Handle BUILT_IN_ALIGNED_ALLOC.
+
+2014-04-28 Richard Biener <rguenther@suse.de>
+
* tree-vrp.c (vrp_var_may_overflow): Remove.
(vrp_visit_phi_node): Rather than bumping to +-INF possibly
with overflow immediately bump to one before that value and
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index a31cd3c..8d8ac30 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,8 @@
+2014-04-28 Richard Biener <rguenther@suse.de>
+
+ PR middle-end/60092
+ * gcc-interface/utils.c: Define flag_isoc11.
+
2014-04-26 Eric Botcazou <ebotcazou@adacore.com>
* gnatvsn.ads (Library_Version): Bump to 4.10.
diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c
index 4814f9a..c81ab00 100644
--- a/gcc/ada/gcc-interface/utils.c
+++ b/gcc/ada/gcc-interface/utils.c
@@ -6519,6 +6519,7 @@ def_builtin_1 (enum built_in_function fncode,
static int flag_isoc94 = 0;
static int flag_isoc99 = 0;
+static int flag_isoc11 = 0;
/* Install what the common builtins.def offers. */
diff --git a/gcc/builtins.def b/gcc/builtins.def
index 5a76ba3..5b902d8 100644
--- a/gcc/builtins.def
+++ b/gcc/builtins.def
@@ -111,6 +111,13 @@ along with GCC; see the file COPYING3. If not see
DEF_BUILTIN (ENUM, "__builtin_" NAME, BUILT_IN_NORMAL, TYPE, TYPE, \
true, true, !flag_isoc99, ATTRS, targetm.libc_has_function (function_c99_misc), true)
+/* Like DEF_LIB_BUILTIN, except that the function is only a part of
+ the standard in C11 or above. */
+#undef DEF_C11_BUILTIN
+#define DEF_C11_BUILTIN(ENUM, NAME, TYPE, ATTRS) \
+ DEF_BUILTIN (ENUM, "__builtin_" NAME, BUILT_IN_NORMAL, TYPE, TYPE, \
+ true, true, !flag_isoc11, ATTRS, targetm.libc_has_function (function_c11_misc), true)
+
/* Like DEF_C99_BUILTIN, but for complex math functions. */
#undef DEF_C99_COMPL_BUILTIN
#define DEF_C99_COMPL_BUILTIN(ENUM, NAME, TYPE, ATTRS) \
@@ -223,6 +230,7 @@ DEF_C99_BUILTIN (BUILT_IN_ACOSH, "acosh", BT_FN_DOUBLE_DOUBLE, ATTR_MATHF
DEF_C99_BUILTIN (BUILT_IN_ACOSHF, "acoshf", BT_FN_FLOAT_FLOAT, ATTR_MATHFN_FPROUNDING_ERRNO)
DEF_C99_BUILTIN (BUILT_IN_ACOSHL, "acoshl", BT_FN_LONGDOUBLE_LONGDOUBLE, ATTR_MATHFN_FPROUNDING_ERRNO)
DEF_C99_C90RES_BUILTIN (BUILT_IN_ACOSL, "acosl", BT_FN_LONGDOUBLE_LONGDOUBLE, ATTR_MATHFN_FPROUNDING_ERRNO)
+DEF_C11_BUILTIN (BUILT_IN_ALIGNED_ALLOC, "aligned_alloc", BT_FN_PTR_SIZE_SIZE, ATTR_MALLOC_NOTHROW_LIST)
DEF_LIB_BUILTIN (BUILT_IN_ASIN, "asin", BT_FN_DOUBLE_DOUBLE, ATTR_MATHFN_FPROUNDING_ERRNO)
DEF_C99_C90RES_BUILTIN (BUILT_IN_ASINF, "asinf", BT_FN_FLOAT_FLOAT, ATTR_MATHFN_FPROUNDING_ERRNO)
DEF_C99_BUILTIN (BUILT_IN_ASINH, "asinh", BT_FN_DOUBLE_DOUBLE, ATTR_MATHFN_FPROUNDING)
diff --git a/gcc/coretypes.h b/gcc/coretypes.h
index d07a604..d70fb11 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -194,7 +194,8 @@ enum function_class {
function_c94,
function_c99_misc,
function_c99_math_complex,
- function_sincos
+ function_sincos,
+ function_c11_misc
};
/* Memory model types for the __atomic* builtins.
diff --git a/gcc/lto/ChangeLog b/gcc/lto/ChangeLog
index f1ecec9..edb5bb9 100644
--- a/gcc/lto/ChangeLog
+++ b/gcc/lto/ChangeLog
@@ -1,3 +1,8 @@
+2014-04-28 Richard Biener <rguenther@suse.de>
+
+ PR middle-end/60092
+ * lto-lang.c: Define flag_isoc11.
+
2014-04-23 David Malcolm <dmalcolm@redhat.com>
* lto-partition.c (add_references_to_partition): Update for
diff --git a/gcc/lto/lto-lang.c b/gcc/lto/lto-lang.c
index f60d212..339bebf 100644
--- a/gcc/lto/lto-lang.c
+++ b/gcc/lto/lto-lang.c
@@ -192,6 +192,7 @@ static GTY(()) tree signed_size_type_node;
/* Flags needed to process builtins.def. */
int flag_isoc94;
int flag_isoc99;
+int flag_isoc11;
/* Attribute handlers. */
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 261bb98..41c0821 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,11 @@
2014-04-28 Richard Biener <rguenther@suse.de>
+ PR middle-end/60092
+ * gcc.dg/tree-ssa/alias-32.c: New testcase.
+ * gcc.dg/vect/pr60092.c: Likewise.
+
+2014-04-28 Richard Biener <rguenther@suse.de>
+
* gcc.dg/tree-ssa/vrp91.c: New testcase.
* gcc.dg/Wstrict-overflow-14.c: XFAIL.
* gcc.dg/Wstrict-overflow-15.c: Likewise.
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/alias-32.c b/gcc/testsuite/gcc.dg/tree-ssa/alias-32.c
new file mode 100644
index 0000000..5d0dcc2
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/alias-32.c
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-cddce1" } */
+
+int bar (short *p)
+{
+ int res = *p;
+ struct { int *q1; int *q2; } q;
+ q.q1 = __builtin_aligned_alloc (128, 128 * sizeof (int));
+ q.q2 = __builtin_aligned_alloc (128, 128 * sizeof (int));
+ *q.q1 = 1;
+ *q.q2 = 2;
+ return res + *p + *q.q1 + *q.q2;
+}
+
+/* There should be only one load from *p left. All stores and all
+ other loads should be removed. Likewise the calls to aligned_alloc. */
+
+/* { dg-final { scan-tree-dump-times "\\\*\[^ \]" 1 "cddce1" } } */
+/* { dg-final { scan-tree-dump-not "aligned_alloc" "cddce1" } } */
+/* { dg-final { cleanup-tree-dump "cddce1" } } */
diff --git a/gcc/testsuite/gcc.dg/vect/pr60092.c b/gcc/testsuite/gcc.dg/vect/pr60092.c
new file mode 100644
index 0000000..e03c625
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr60092.c
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target vect_int } */
+
+int *foo (int n)
+{
+ int *p = __builtin_aligned_alloc (256, n * sizeof (int));
+ int *q = __builtin_aligned_alloc (256, n * sizeof (int));
+ bar (q);
+ int i;
+ for (i = 0; i < n; ++i)
+ p[i] = q[i] + q[i];
+ return p;
+}
+
+/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */
+/* { dg-final { scan-tree-dump-not "Peeling for alignment will be applied" "vect" } } */
+/* { dg-final { scan-tree-dump-not "Vectorizing an unaligned access" "vect" } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c
index 2c57a17..cd2c110 100644
--- a/gcc/tree-ssa-alias.c
+++ b/gcc/tree-ssa-alias.c
@@ -1646,6 +1646,7 @@ ref_maybe_used_by_call_p_1 (gimple call, ao_ref *ref)
case BUILT_IN_FREE:
case BUILT_IN_MALLOC:
case BUILT_IN_POSIX_MEMALIGN:
+ case BUILT_IN_ALIGNED_ALLOC:
case BUILT_IN_CALLOC:
case BUILT_IN_ALLOCA:
case BUILT_IN_ALLOCA_WITH_ALIGN:
@@ -1956,6 +1957,7 @@ call_may_clobber_ref_p_1 (gimple call, ao_ref *ref)
/* Allocating memory does not have any side-effects apart from
being the definition point for the pointer. */
case BUILT_IN_MALLOC:
+ case BUILT_IN_ALIGNED_ALLOC:
case BUILT_IN_CALLOC:
case BUILT_IN_STRDUP:
case BUILT_IN_STRNDUP:
diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c
index 257d108..5e6b4d8 100644
--- a/gcc/tree-ssa-ccp.c
+++ b/gcc/tree-ssa-ccp.c
@@ -1762,6 +1762,25 @@ evaluate_stmt (gimple stmt)
val = bit_value_assume_aligned (stmt, NULL_TREE, val, false);
break;
+ case BUILT_IN_ALIGNED_ALLOC:
+ {
+ tree align = get_constant_value (gimple_call_arg (stmt, 0));
+ if (align
+ && tree_fits_uhwi_p (align))
+ {
+ unsigned HOST_WIDE_INT aligni = tree_to_uhwi (align);
+ if (aligni > 1
+ /* align must be power-of-two */
+ && (aligni & (aligni - 1)) == 0)
+ {
+ val.lattice_val = CONSTANT;
+ val.value = build_int_cst (ptr_type_node, 0);
+ val.mask = double_int::from_shwi (-aligni);
+ }
+ }
+ break;
+ }
+
default:;
}
}
diff --git a/gcc/tree-ssa-dce.c b/gcc/tree-ssa-dce.c
index 6389f23..e1edb2e 100644
--- a/gcc/tree-ssa-dce.c
+++ b/gcc/tree-ssa-dce.c
@@ -231,6 +231,7 @@ mark_stmt_if_obviously_necessary (gimple stmt, bool aggressive)
switch (DECL_FUNCTION_CODE (callee))
{
case BUILT_IN_MALLOC:
+ case BUILT_IN_ALIGNED_ALLOC:
case BUILT_IN_CALLOC:
case BUILT_IN_ALLOCA:
case BUILT_IN_ALLOCA_WITH_ALIGN:
@@ -573,6 +574,7 @@ mark_all_reaching_defs_necessary_1 (ao_ref *ref ATTRIBUTE_UNUSED,
switch (DECL_FUNCTION_CODE (callee))
{
case BUILT_IN_MALLOC:
+ case BUILT_IN_ALIGNED_ALLOC:
case BUILT_IN_CALLOC:
case BUILT_IN_ALLOCA:
case BUILT_IN_ALLOCA_WITH_ALIGN:
@@ -776,7 +778,8 @@ propagate_necessity (bool aggressive)
&& is_gimple_call (def_stmt = SSA_NAME_DEF_STMT (ptr))
&& (def_callee = gimple_call_fndecl (def_stmt))
&& DECL_BUILT_IN_CLASS (def_callee) == BUILT_IN_NORMAL
- && (DECL_FUNCTION_CODE (def_callee) == BUILT_IN_MALLOC
+ && (DECL_FUNCTION_CODE (def_callee) == BUILT_IN_ALIGNED_ALLOC
+ || DECL_FUNCTION_CODE (def_callee) == BUILT_IN_MALLOC
|| DECL_FUNCTION_CODE (def_callee) == BUILT_IN_CALLOC))
continue;
}
@@ -822,6 +825,7 @@ propagate_necessity (bool aggressive)
&& (DECL_FUNCTION_CODE (callee) == BUILT_IN_MEMSET
|| DECL_FUNCTION_CODE (callee) == BUILT_IN_MEMSET_CHK
|| DECL_FUNCTION_CODE (callee) == BUILT_IN_MALLOC
+ || DECL_FUNCTION_CODE (callee) == BUILT_IN_ALIGNED_ALLOC
|| DECL_FUNCTION_CODE (callee) == BUILT_IN_CALLOC
|| DECL_FUNCTION_CODE (callee) == BUILT_IN_FREE
|| DECL_FUNCTION_CODE (callee) == BUILT_IN_VA_END
@@ -1229,7 +1233,8 @@ eliminate_unnecessary_stmts (void)
special logic we apply to malloc/free pair removal. */
&& (!(call = gimple_call_fndecl (stmt))
|| DECL_BUILT_IN_CLASS (call) != BUILT_IN_NORMAL
- || (DECL_FUNCTION_CODE (call) != BUILT_IN_MALLOC
+ || (DECL_FUNCTION_CODE (call) != BUILT_IN_ALIGNED_ALLOC
+ && DECL_FUNCTION_CODE (call) != BUILT_IN_MALLOC
&& DECL_FUNCTION_CODE (call) != BUILT_IN_CALLOC
&& DECL_FUNCTION_CODE (call) != BUILT_IN_ALLOCA
&& (DECL_FUNCTION_CODE (call)