aboutsummaryrefslogtreecommitdiff
path: root/gcc/internal-fn.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2015-12-09 14:42:06 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2015-12-09 14:42:06 +0100
commit08554c26c4541be7d6ec0fec4d8810e97f56caab (patch)
tree502f1c7099772546308e02600f4ab82c0d8b35ab /gcc/internal-fn.c
parente56c602ea3335648e81411442a66e52dd129dc3b (diff)
downloadgcc-08554c26c4541be7d6ec0fec4d8810e97f56caab.zip
gcc-08554c26c4541be7d6ec0fec4d8810e97f56caab.tar.gz
gcc-08554c26c4541be7d6ec0fec4d8810e97f56caab.tar.bz2
re PR tree-optimization/68786 (Aligned masked store is generated for unaligned pointer)
PR tree-optimization/68786 * tree-if-conv.c: Include builtins.h. (predicate_mem_writes): Put result of get_object_alignment (ref) into second argument's value. * tree-vect-stmts.c (vectorizable_mask_load_store): Put minimum pointer alignment into second argument's value. * tree-data-ref.c (get_references_in_stmt): Use value of second argument for build_aligned_type, and only the type to build a zero second argument for MEM_REF. * internal-fn.c (expand_mask_load_optab_fn, expand_mask_store_optab_fn): Likewise. From-SVN: r231454
Diffstat (limited to 'gcc/internal-fn.c')
-rw-r--r--gcc/internal-fn.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/gcc/internal-fn.c b/gcc/internal-fn.c
index 2be2d88..3ceaffe 100644
--- a/gcc/internal-fn.c
+++ b/gcc/internal-fn.c
@@ -1911,16 +1911,20 @@ static void
expand_mask_load_optab_fn (internal_fn, gcall *stmt, convert_optab optab)
{
struct expand_operand ops[3];
- tree type, lhs, rhs, maskt;
+ tree type, lhs, rhs, maskt, ptr;
rtx mem, target, mask;
+ unsigned align;
maskt = gimple_call_arg (stmt, 2);
lhs = gimple_call_lhs (stmt);
if (lhs == NULL_TREE)
return;
type = TREE_TYPE (lhs);
- rhs = fold_build2 (MEM_REF, type, gimple_call_arg (stmt, 0),
- gimple_call_arg (stmt, 1));
+ ptr = build_int_cst (TREE_TYPE (gimple_call_arg (stmt, 1)), 0);
+ align = tree_to_shwi (gimple_call_arg (stmt, 1));
+ if (TYPE_ALIGN (type) != align)
+ type = build_aligned_type (type, align);
+ rhs = fold_build2 (MEM_REF, type, gimple_call_arg (stmt, 0), ptr);
mem = expand_expr (rhs, NULL_RTX, VOIDmode, EXPAND_WRITE);
gcc_assert (MEM_P (mem));
@@ -1940,14 +1944,18 @@ static void
expand_mask_store_optab_fn (internal_fn, gcall *stmt, convert_optab optab)
{
struct expand_operand ops[3];
- tree type, lhs, rhs, maskt;
+ tree type, lhs, rhs, maskt, ptr;
rtx mem, reg, mask;
+ unsigned align;
maskt = gimple_call_arg (stmt, 2);
rhs = gimple_call_arg (stmt, 3);
type = TREE_TYPE (rhs);
- lhs = fold_build2 (MEM_REF, type, gimple_call_arg (stmt, 0),
- gimple_call_arg (stmt, 1));
+ ptr = build_int_cst (TREE_TYPE (gimple_call_arg (stmt, 1)), 0);
+ align = tree_to_shwi (gimple_call_arg (stmt, 1));
+ if (TYPE_ALIGN (type) != align)
+ type = build_aligned_type (type, align);
+ lhs = fold_build2 (MEM_REF, type, gimple_call_arg (stmt, 0), ptr);
mem = expand_expr (lhs, NULL_RTX, VOIDmode, EXPAND_WRITE);
gcc_assert (MEM_P (mem));