summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2014-10-15 07:37:20 +0000
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2014-10-15 07:37:20 +0000
commit876d57cdca1bdf831db277fdbc1c0292b903e7b4 (patch)
tree0a19fd38239b57040a2213728734c9f7034fd1f8
parent7cd65228b203a01957994114ec53318cb2ab413c (diff)
downloadppe42-gcc-876d57cdca1bdf831db277fdbc1c0292b903e7b4.tar.gz
ppe42-gcc-876d57cdca1bdf831db277fdbc1c0292b903e7b4.zip
2014-10-15 Richard Biener <rguenther@suse.de>
Backport from mainline 2014-08-15 Richard Biener <rguenther@suse.de> PR tree-optimization/62031 * tree-data-ref.c (dr_analyze_indices): Do not set DR_UNCONSTRAINED_BASE. (dr_may_alias_p): All indirect accesses have to go the formerly DR_UNCONSTRAINED_BASE path. * tree-data-ref.h (struct indices): Remove unconstrained_base member. (DR_UNCONSTRAINED_BASE): Remove. * gcc.dg/torture/pr62031.c: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_9-branch@216236 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog14
-rw-r--r--gcc/testsuite/ChangeLog8
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr62031.c52
-rw-r--r--gcc/tree-data-ref.c37
-rw-r--r--gcc/tree-data-ref.h5
5 files changed, 101 insertions, 15 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index e735af1ff50..da28076e285 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,17 @@
+2014-10-15 Richard Biener <rguenther@suse.de>
+
+ Backport from mainline
+ 2014-08-15 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/62031
+ * tree-data-ref.c (dr_analyze_indices): Do not set
+ DR_UNCONSTRAINED_BASE.
+ (dr_may_alias_p): All indirect accesses have to go the
+ formerly DR_UNCONSTRAINED_BASE path.
+ * tree-data-ref.h (struct indices): Remove
+ unconstrained_base member.
+ (DR_UNCONSTRAINED_BASE): Remove.
+
2014-10-12 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
Backport from mainline r215880
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 9fb71a4a33e..4add23c9c0d 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2014-10-15 Richard Biener <rguenther@suse.de>
+
+ Backport from mainline
+ 2014-08-15 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/62031
+ * gcc.dg/torture/pr62031.c: New testcase.
+
2014-10-12 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
Backport from mainline r215880
diff --git a/gcc/testsuite/gcc.dg/torture/pr62031.c b/gcc/testsuite/gcc.dg/torture/pr62031.c
new file mode 100644
index 00000000000..f0dcef44b1d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr62031.c
@@ -0,0 +1,52 @@
+/* { dg-do run } */
+
+#include <stdlib.h>
+
+#define NUM_OF_STATES 4
+typedef unsigned int entry_t[2];
+typedef struct entries_item { entry_t metricEntries_[0]; } entries_item_t;
+
+void __attribute__((noinline,noclone))
+test_00(size_t numOfStates, entries_item_t* p_bm,
+ const unsigned int* polyArray,
+ size_t polyArraySize)
+{
+ size_t idx;
+ unsigned int hlp0, hlp1;
+ for (idx = 0; idx < numOfStates; ++idx)
+ {
+ size_t idy;
+
+ hlp0 = (idx << 1) | 0x00;
+ hlp1 = (idx << 1) | 0x01;
+ p_bm->metricEntries_[idx][0] = 0;
+ p_bm->metricEntries_[idx][1] = 0;
+ for (idy = 0; idy < polyArraySize; ++idy)
+ {
+ p_bm->metricEntries_[idx][0]
+ |= __builtin_parity(hlp0 & polyArray[idy]) << idy;
+ p_bm->metricEntries_[idx][1]
+ |= __builtin_parity(hlp1 & polyArray[idy]) << idy;
+ }
+ }
+}
+
+int main()
+{
+ unsigned int polyArray[] = { 0x07, 0x05 };
+ entries_item_t* pBranchMetrics;
+ pBranchMetrics = malloc(sizeof(entry_t) * NUM_OF_STATES);
+ test_00(NUM_OF_STATES, pBranchMetrics, polyArray,
+ sizeof(polyArray) / sizeof(polyArray[0]));
+ if (pBranchMetrics->metricEntries_[0][0] != 0
+ || pBranchMetrics->metricEntries_[0][1] != 3
+ || pBranchMetrics->metricEntries_[1][0] != 1
+ || pBranchMetrics->metricEntries_[1][1] != 2
+ || pBranchMetrics->metricEntries_[2][0] != 3
+ || pBranchMetrics->metricEntries_[2][1] != 0
+ || pBranchMetrics->metricEntries_[3][0] != 2
+ || pBranchMetrics->metricEntries_[3][1] != 1)
+ abort ();
+ free(pBranchMetrics);
+ return 0;
+}
diff --git a/gcc/tree-data-ref.c b/gcc/tree-data-ref.c
index 01d0a7a79d8..a15494a89bf 100644
--- a/gcc/tree-data-ref.c
+++ b/gcc/tree-data-ref.c
@@ -982,7 +982,6 @@ dr_analyze_indices (struct data_reference *dr, loop_p nest, loop_p loop)
ref = fold_build2_loc (EXPR_LOCATION (ref),
MEM_REF, TREE_TYPE (ref),
base, memoff);
- DR_UNCONSTRAINED_BASE (dr) = true;
access_fns.safe_push (access_fn);
}
}
@@ -1389,14 +1388,20 @@ dr_may_alias_p (const struct data_reference *a, const struct data_reference *b,
return false;
}
- /* If we had an evolution in a MEM_REF BASE_OBJECT we do not know
- the size of the base-object. So we cannot do any offset/overlap
- based analysis but have to rely on points-to information only. */
+ /* If we had an evolution in a pointer-based MEM_REF BASE_OBJECT we
+ do not know the size of the base-object. So we cannot do any
+ offset/overlap based analysis but have to rely on points-to
+ information only. */
if (TREE_CODE (addr_a) == MEM_REF
- && DR_UNCONSTRAINED_BASE (a))
+ && TREE_CODE (TREE_OPERAND (addr_a, 0)) == SSA_NAME)
{
- if (TREE_CODE (addr_b) == MEM_REF
- && DR_UNCONSTRAINED_BASE (b))
+ /* For true dependences we can apply TBAA. */
+ if (flag_strict_aliasing
+ && DR_IS_WRITE (a) && DR_IS_READ (b)
+ && !alias_sets_conflict_p (get_alias_set (DR_REF (a)),
+ get_alias_set (DR_REF (b))))
+ return false;
+ if (TREE_CODE (addr_b) == MEM_REF)
return ptr_derefs_may_alias_p (TREE_OPERAND (addr_a, 0),
TREE_OPERAND (addr_b, 0));
else
@@ -1404,9 +1409,21 @@ dr_may_alias_p (const struct data_reference *a, const struct data_reference *b,
build_fold_addr_expr (addr_b));
}
else if (TREE_CODE (addr_b) == MEM_REF
- && DR_UNCONSTRAINED_BASE (b))
- return ptr_derefs_may_alias_p (build_fold_addr_expr (addr_a),
- TREE_OPERAND (addr_b, 0));
+ && TREE_CODE (TREE_OPERAND (addr_b, 0)) == SSA_NAME)
+ {
+ /* For true dependences we can apply TBAA. */
+ if (flag_strict_aliasing
+ && DR_IS_WRITE (a) && DR_IS_READ (b)
+ && !alias_sets_conflict_p (get_alias_set (DR_REF (a)),
+ get_alias_set (DR_REF (b))))
+ return false;
+ if (TREE_CODE (addr_a) == MEM_REF)
+ return ptr_derefs_may_alias_p (TREE_OPERAND (addr_a, 0),
+ TREE_OPERAND (addr_b, 0));
+ else
+ return ptr_derefs_may_alias_p (build_fold_addr_expr (addr_a),
+ TREE_OPERAND (addr_b, 0));
+ }
/* Otherwise DR_BASE_OBJECT is an access that covers the whole object
that is being subsetted in the loop nest. */
diff --git a/gcc/tree-data-ref.h b/gcc/tree-data-ref.h
index 9d819e4a0ff..f4f6832af11 100644
--- a/gcc/tree-data-ref.h
+++ b/gcc/tree-data-ref.h
@@ -81,10 +81,6 @@ struct indices
/* A list of chrecs. Access functions of the indices. */
vec<tree> access_fns;
-
- /* Whether BASE_OBJECT is an access representing the whole object
- or whether the access could not be constrained. */
- bool unconstrained_base;
};
struct dr_alias
@@ -195,7 +191,6 @@ struct data_reference
#define DR_STMT(DR) (DR)->stmt
#define DR_REF(DR) (DR)->ref
#define DR_BASE_OBJECT(DR) (DR)->indices.base_object
-#define DR_UNCONSTRAINED_BASE(DR) (DR)->indices.unconstrained_base
#define DR_ACCESS_FNS(DR) (DR)->indices.access_fns
#define DR_ACCESS_FN(DR, I) DR_ACCESS_FNS (DR)[I]
#define DR_NUM_DIMENSIONS(DR) DR_ACCESS_FNS (DR).length ()
OpenPOWER on IntegriCloud