aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2014-04-14 11:49:42 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2014-04-14 11:49:42 +0000
commitb0f1bf3681b1f835f6402538e0f6471c72a465eb (patch)
treede7d0e7139d874aa77d18b13a0eb4a8e293771f4
parent727987844249aafe00ffaf7a8030564c1f731607 (diff)
downloadgcc-b0f1bf3681b1f835f6402538e0f6471c72a465eb.zip
gcc-b0f1bf3681b1f835f6402538e0f6471c72a465eb.tar.gz
gcc-b0f1bf3681b1f835f6402538e0f6471c72a465eb.tar.bz2
re PR c/60819 (dse1 removing not-dead insn (aliasing issue?))
2014-04-14 Richard Biener <rguenther@suse.de> Marc Glisse <marc.glisse@inria.fr> PR c/60819 c-family/ * c-common.c (convert_vector_to_pointer_for_subscript): Properly apply may-alias the scalar pointer type when applicable. * gcc.target/i386/vec-may_alias.c: New testcase. Co-Authored-By: Marc Glisse <marc.glisse@inria.fr> From-SVN: r209365
-rw-r--r--gcc/c-family/ChangeLog7
-rw-r--r--gcc/c-family/c-common.c15
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/gcc.target/i386/vec-may_alias.c25
4 files changed, 52 insertions, 1 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index f510bcc..206b47b 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -1,3 +1,10 @@
+2014-04-14 Richard Biener <rguenther@suse.de>
+ Marc Glisse <marc.glisse@inria.fr>
+
+ PR c/60819
+ * c-common.c (convert_vector_to_pointer_for_subscript): Properly
+ apply may-alias the scalar pointer type when applicable.
+
2014-04-12 Igor Zamyatin <igor.zamyatin@intel.com>
PR middle-end/60467
diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index 1d56bc0..c0e247b 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -11784,8 +11784,21 @@ convert_vector_to_pointer_for_subscript (location_t loc,
c_common_mark_addressable_vec (*vecp);
type = build_qualified_type (TREE_TYPE (type), TYPE_QUALS (type));
- type = build_pointer_type (type);
type1 = build_pointer_type (TREE_TYPE (*vecp));
+ bool ref_all = TYPE_REF_CAN_ALIAS_ALL (type1);
+ if (!ref_all
+ && !DECL_P (*vecp))
+ {
+ /* If the original vector isn't declared may_alias and it
+ isn't a bare vector look if the subscripting would
+ alias the vector we subscript, and if not, force ref-all. */
+ alias_set_type vecset = get_alias_set (*vecp);
+ alias_set_type sset = get_alias_set (type);
+ if (!alias_sets_must_conflict_p (sset, vecset)
+ && !alias_set_subset_of (sset, vecset))
+ ref_all = true;
+ }
+ type = build_pointer_type_for_mode (type, ptr_mode, ref_all);
*vecp = build1 (ADDR_EXPR, type1, *vecp);
*vecp = convert (type, *vecp);
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index e944a0e..3665588 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2014-04-14 Richard Biener <rguenther@suse.de>
+ Marc Glisse <marc.glisse@inria.fr>
+
+ PR c/60819
+ * gcc.target/i386/vec-may_alias.c: New testcase.
+
2014-04-14 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
* lib/target-supports.exp
diff --git a/gcc/testsuite/gcc.target/i386/vec-may_alias.c b/gcc/testsuite/gcc.target/i386/vec-may_alias.c
new file mode 100644
index 0000000..e970497
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/vec-may_alias.c
@@ -0,0 +1,25 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -w -Wno-abi" } */
+
+typedef int v2si __attribute__ ((vector_size (8)));
+typedef short v4hi __attribute__ ((vector_size (8)));
+typedef short v4hia __attribute__ ((vector_size (8), may_alias));
+
+__attribute__ ((noinline, noclone))
+int f (v2si A, int N)
+{ return ((v4hia)A)[N]; }
+
+__attribute__ ((noinline, noclone))
+int g (v2si A, int N)
+{ return ((v4hi)A)[N]; }
+
+int main()
+{
+ v2si x = { 0, 0 }, y = { 1, 1 };
+ if (f (x, 0) || f (x, 1) || f (x, 2) || f (x, 3))
+ __builtin_abort ();
+ if (g (y, 0) != 1 || g (y, 1) || g (y, 2) != 1 || g (y, 3))
+ __builtin_abort ();
+ return 0;
+}
+