From 0ea6d5cac3509cbbd1a09426836b50c9b858d040 Mon Sep 17 00:00:00 2001 From: rsandifo Date: Tue, 20 Feb 2018 14:44:24 +0000 Subject: Fix incorrect TARGET_MEM_REF alignment (PR 84419) expand_call_mem_ref checks for TARGET_MEM_REFs that have compatible type, but it didn't then go on to install the specific type we need, which might have different alignment due to: if (TYPE_ALIGN (type) != align) type = build_aligned_type (type, align); This was causing masked stores to be incorrectly marked as aligned on AVX512. 2018-02-20 Richard Sandiford gcc/ PR tree-optimization/84419 * internal-fn.c (expand_call_mem_ref): Create a TARGET_MEM_REF with the required type if its current type is compatible but different. gcc/testsuite/ PR tree-optimization/84419 * gcc.dg/vect/pr84419.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@257847 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/internal-fn.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'gcc/internal-fn.c') diff --git a/gcc/internal-fn.c b/gcc/internal-fn.c index 88adaea4c86..da205c9d68a 100644 --- a/gcc/internal-fn.c +++ b/gcc/internal-fn.c @@ -2444,11 +2444,14 @@ expand_call_mem_ref (tree type, gcall *stmt, int index) && types_compatible_p (TREE_TYPE (mem), type)) { tree offset = TMR_OFFSET (mem); - if (alias_ptr_type != TREE_TYPE (offset) || !integer_zerop (offset)) + if (type != TREE_TYPE (mem) + || alias_ptr_type != TREE_TYPE (offset) + || !integer_zerop (offset)) { mem = copy_node (mem); TMR_OFFSET (mem) = wide_int_to_tree (alias_ptr_type, wi::to_poly_wide (offset)); + TREE_TYPE (mem) = type; } return mem; } -- cgit v1.2.1