From patchwork Wed Jun 28 13:45:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 106535 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1034321qge; Wed, 28 Jun 2017 06:46:04 -0700 (PDT) X-Received: by 10.101.88.197 with SMTP id e5mr10543064pgu.144.1498657564014; Wed, 28 Jun 2017 06:46:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498657564; cv=none; d=google.com; s=arc-20160816; b=YWbqWzCZNeWEqw+yw/51fzFtDHsup6BxIGbg45JRZue2I8TCUxf9zfthL2TmREGEeB NgkkzVMQr1D+nKGFyYuuL9RAp4jOrkwK+lR15VRysvfpTFEjxxmKdpgLSwLrpz/tOP4p 6abP6wDL2us5/uWLUubNQNb9YwaoW9ij3dsILxyJf6eAzAyBWrTgazZmzkVeIuNDiEjw L2uTUeOBBdGTwN5d7jbLbxAkQQPip8Xv/2Mfh6vE5xH9N58wneL0dvv5q7OC+Uz94h19 iyYbIQWJyQqw5hzjHfLKWDQ2ebrxSJrA1Aqs3QxET5vdf98Hf77XVBGWVVafvjYDPZcg 6A6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:message-id:date:subject:mail-followup-to:to :from:delivered-to:sender:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=LvehiMA2QPT0yqShdSYNmV7oao75g3BESoeoAgmOkz0=; b=oRWiBmr4CC69Ftj0ypjpAzNk3vrhAUMGwf0RgZyPVwwpJDoT0BBJ2qGoesGYsPIg1V zJSqiwxI/yZEc2ILsGaADtoB3SUWaD3Z95scH+9XHtFY7QVvajEevBfVgPc5el3qUfZi Q8yZWbitF+1FMrSdxSF4fuGFNyPQndKchrz5hspnrFufiiEzNURo5IgeBVY9I/TYJwYQ phK3reXAhK65NPKQ6CY9/3Vxc5+6pI+ket2K7Imdroi5LggecYPR7MBH46gn63+eoKAb OM0DB7UIjdVG2a2VLJAy8HdfANfWCTvQ4KafDVUQoCJD+6FzXRv1R9sqhLDXNK45ku9F WJEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=nTGrxA31; spf=pass (google.com: domain of gcc-patches-return-457070-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-457070-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id n16si1766335pll.347.2017.06.28.06.46.03 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Jun 2017 06:46:04 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-457070-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=nTGrxA31; spf=pass (google.com: domain of gcc-patches-return-457070-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-457070-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type; q=dns; s= default; b=AeDEFzln1WnZOoPzAutleAV1f79cWsZrsu5Bzq2Ss2PLNCf26yHQK vibay2LpGBqG3wP15JWqaVlu41Ay2ipi5K0+U8JqFJGl+qDgfPHVajoQN9pDWpTj WdHHVW1/KsAinnjg3GagjoWs7KuiyiQfT8G+SoJuiTa6Jn6qwBx0Fo= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type; s= default; bh=J7+L2+i3pp9rTtva3YCqjLWnBPU=; b=nTGrxA310mW9IsJXglCh SbKi9kjA6nQHbE4n5TvCmVAtCt6ry30nZyIsJ5JsPrisDcCB7vDny1AdtziMZINj FjK2gWWXrNlRdnS1opEU+TCulghtTpFmNXZajT9gsTs9tufDHHY0FYajQV7X9gom IsaTOkeTi4j0pKgpk3+mQhQ= Received: (qmail 98743 invoked by alias); 28 Jun 2017 13:45:48 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 92696 invoked by uid 89); 28 Jun 2017 13:45:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=recording X-HELO: mail-wr0-f172.google.com Received: from mail-wr0-f172.google.com (HELO mail-wr0-f172.google.com) (209.85.128.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 28 Jun 2017 13:45:37 +0000 Received: by mail-wr0-f172.google.com with SMTP id r103so174869202wrb.0 for ; Wed, 28 Jun 2017 06:45:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:mail-followup-to:subject:date:message-id :user-agent:mime-version; bh=LvehiMA2QPT0yqShdSYNmV7oao75g3BESoeoAgmOkz0=; b=uUz9aAuUOEu5MIY5w4BDO4eaVVtWUOpr5q8Y8f2hkLxslUUuoCUqfYjlEV1BJug9sI JwEbpTj3wdTjIg2nrPBKAg2zBtuk+l5GBhEFoEj5nzgnzaLGM7+UKQWMyLigTEA6lc79 X612r+SDNIG1ZHeerg5eNFPaHMUHulobl+FyB5vtvHCvCHyDWvRwVSEhoBKyajmuFm09 y/Z6uRtQ0t9lNDCWrOp8rvlI2sTB6RJNb29uS0CfL26kgJ3CyGPo3gS0293rwDUyHCgk EIy94qPKdaGwHvGgjmzTuElLXuBuykmJ831kBxE7CsENzFYppuszrnMMhm9nyXaO4B9f ASzA== X-Gm-Message-State: AKS2vOymO9WVjgrtOH9JAFyCpzM8+JpFE8fqJ2tOUIO+pcStl7eYZU1B U2Lym4oOFVDf5jr5EsUqCw== X-Received: by 10.223.136.216 with SMTP id g24mr18478557wrg.199.1498657533400; Wed, 28 Jun 2017 06:45:33 -0700 (PDT) Received: from localhost (92.40.249.75.threembb.co.uk. [92.40.249.75]) by smtp.gmail.com with ESMTPSA id z101sm2689227wrb.41.2017.06.28.06.45.31 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 28 Jun 2017 06:45:32 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: Pool alignment information for common bases Date: Wed, 28 Jun 2017 14:45:30 +0100 Message-ID: <87injg6xad.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 We know that if a vectorised loop is reached, all statements in that loop execute at least once, so it should be safe to pool the alignment information for all the statements we're vectorising. The only catch is that DR_REFs for masked loads and stores only occur if the mask value is nonzero. For example, in: struct s __attribute__((aligned(32))) { int misaligner; int array[N]; }; int *ptr; for (int i = 0; i < n; ++i) ptr[i] = c[i] ? ((struct s *) (ptr - 1))->array[i] : 0; we can only guarantee that ptr points to a "struct s" if at least one c[i] is true. This patch adds a DR_IS_CONDITIONAL_IN_STMT flag to record whether the DR_REF is guaranteed to occur every time that the statement executes to completion. It then pools the alignment information for references that aren't conditional in this sense. Tested on aarch64-linux-gnu and x86_64-linux-gnu. OK to install? Richard 2017-06-28 Richard Sandiford gcc/ * tree-vectorizer.h: Include tree-hash-traits.h. (vec_base_alignments): New typedef. (vec_info): Add a base_alignments field. (vect_record_base_alignments: Declare. * tree-data-ref.h (data_reference): Add an is_conditional_in_stmt field. (DR_IS_CONDITIONAL_IN_STMT): New macro. (create_data_ref): Add an is_conditional_in_stmt argument. * tree-data-ref.c (create_data_ref): Likewise. Use it to initialize the is_conditional_in_stmt field. (data_ref_loc): Add an is_conditional_in_stmt field. (get_references_in_stmt): Set the is_conditional_in_stmt field. (find_data_references_in_stmt): Update call to create_data_ref. (graphite_find_data_references_in_stmt): Likewise. * tree-ssa-loop-prefetch.c (determine_loop_nest_reuse): Likewise. * tree-vect-data-refs.c (vect_analyze_data_refs): Likewise. (vect_record_base_alignment): New function. (vect_record_base_alignments): Likewise. (vect_compute_data_ref_alignment): Adjust base_addr and aligned_to for nested statements even if we fail to compute a misalignment. Use pooled base alignments for unconditional references. (vect_find_same_alignment_drs): Compare base addresses instead of base objects. (vect_compute_data_ref_alignment): Call vect_record_base_alignments. * tree-vect-slp.c (vect_slp_analyze_bb_1): Likewise. (new_bb_vec_info): Initialize base_alignments. * tree-vect-loop.c (new_loop_vec_info): Likewise. * tree-vectorizer.c (vect_destroy_datarefs): Release base_alignments. gcc/testsuite/ * gcc.dg/vect/pr81136.c: Add scan test. Index: gcc/tree-vectorizer.h =================================================================== --- gcc/tree-vectorizer.h 2017-06-28 14:26:19.653051245 +0100 +++ gcc/tree-vectorizer.h 2017-06-28 14:26:24.027879710 +0100 @@ -22,6 +22,7 @@ Software Foundation; either version 3, o #define GCC_TREE_VECTORIZER_H #include "tree-data-ref.h" +#include "tree-hash-traits.h" #include "target.h" /* Used for naming of new temporaries. */ @@ -84,6 +85,10 @@ struct stmt_info_for_cost { typedef vec stmt_vector_for_cost; +/* Maps base addresses to the largest alignment that we've been able + to calculate for them. */ +typedef hash_map vec_base_alignments; + /************************************************************************ SLP ************************************************************************/ @@ -156,6 +161,10 @@ struct vec_info { /* All data references. */ vec datarefs; + /* Maps the base addresses of all data references in DATAREFS to the + largest alignment that we've been able to calculate for them. */ + vec_base_alignments base_alignments; + /* All data dependences. */ vec ddrs; @@ -1123,6 +1132,7 @@ extern bool vect_prune_runtime_alias_tes extern bool vect_check_gather_scatter (gimple *, loop_vec_info, gather_scatter_info *); extern bool vect_analyze_data_refs (vec_info *, int *); +extern void vect_record_base_alignments (vec_info *); extern tree vect_create_data_ref_ptr (gimple *, tree, struct loop *, tree, tree *, gimple_stmt_iterator *, gimple **, bool, bool *, Index: gcc/tree-data-ref.h =================================================================== --- gcc/tree-data-ref.h 2017-06-28 14:26:19.651051322 +0100 +++ gcc/tree-data-ref.h 2017-06-28 14:26:24.025879789 +0100 @@ -119,6 +119,11 @@ struct data_reference /* True when the data reference is in RHS of a stmt. */ bool is_read; + /* True when the data reference is conditional within STMT, + i.e. if it might not occur even when the statement is executed + and runs to completion. */ + bool is_conditional_in_stmt; + /* The alignment of INNERMOST.base_address, in bits. This is logically part of INNERMOST, but is kept here to avoid unnecessary padding. */ unsigned int base_alignment; @@ -142,6 +147,7 @@ #define DR_ACCESS_FN(DR, I) DR_AC #define DR_NUM_DIMENSIONS(DR) DR_ACCESS_FNS (DR).length () #define DR_IS_READ(DR) (DR)->is_read #define DR_IS_WRITE(DR) (!DR_IS_READ (DR)) +#define DR_IS_CONDITIONAL_IN_STMT(DR) (DR)->is_conditional_in_stmt #define DR_BASE_ADDRESS(DR) (DR)->innermost.base_address #define DR_BASE_ALIGNMENT(DR) (DR)->base_alignment #define DR_OFFSET(DR) (DR)->innermost.offset @@ -355,7 +361,8 @@ extern bool graphite_find_data_reference vec *); tree find_data_references_in_loop (struct loop *, vec *); bool loop_nest_has_data_refs (loop_p loop); -struct data_reference *create_data_ref (loop_p, loop_p, tree, gimple *, bool); +struct data_reference *create_data_ref (loop_p, loop_p, tree, gimple *, bool, + bool); extern bool find_loop_nest (struct loop *, vec *); extern struct data_dependence_relation *initialize_data_dependence_relation (struct data_reference *, struct data_reference *, vec); Index: gcc/tree-data-ref.c =================================================================== --- gcc/tree-data-ref.c 2017-06-28 14:26:19.651051322 +0100 +++ gcc/tree-data-ref.c 2017-06-28 14:26:24.025879789 +0100 @@ -1065,15 +1065,19 @@ free_data_ref (data_reference_p dr) free (dr); } -/* Analyzes memory reference MEMREF accessed in STMT. The reference - is read if IS_READ is true, write otherwise. Returns the - data_reference description of MEMREF. NEST is the outermost loop - in which the reference should be instantiated, LOOP is the loop in - which the data reference should be analyzed. */ +/* Analyze memory reference MEMREF, which is accessed in STMT. + The reference is a read if IS_READ is true, otherwise it is a write. + IS_CONDITIONAL_IN_STMT indicates that the reference is conditional + within STMT, i.e. that it might not occur even if STMT is executed + and runs to completion. + + Return the data_reference description of MEMREF. NEST is the outermost + loop in which the reference should be instantiated, LOOP is the loop + in which the data reference should be analyzed. */ struct data_reference * create_data_ref (loop_p nest, loop_p loop, tree memref, gimple *stmt, - bool is_read) + bool is_read, bool is_conditional_in_stmt) { struct data_reference *dr; @@ -1088,6 +1092,7 @@ create_data_ref (loop_p nest, loop_p loo DR_STMT (dr) = stmt; DR_REF (dr) = memref; DR_IS_READ (dr) = is_read; + DR_IS_CONDITIONAL_IN_STMT (dr) = is_conditional_in_stmt; dr_analyze_innermost (dr, memref, nest != NULL ? loop : NULL); dr_analyze_indices (dr, nest, loop); @@ -4458,6 +4463,11 @@ struct data_ref_loc /* True if the memory reference is read. */ bool is_read; + + /* True if the data reference is conditional within the containing + statement, i.e. if it might not occur even when the statement + is executed and runs to completion. */ + bool is_conditional_in_stmt; }; @@ -4524,6 +4534,7 @@ get_references_in_stmt (gimple *stmt, ve { ref.ref = op1; ref.is_read = true; + ref.is_conditional_in_stmt = false; references->safe_push (ref); } } @@ -4551,6 +4562,7 @@ get_references_in_stmt (gimple *stmt, ve type = TREE_TYPE (gimple_call_arg (stmt, 3)); if (TYPE_ALIGN (type) != align) type = build_aligned_type (type, align); + ref.is_conditional_in_stmt = true; ref.ref = fold_build2 (MEM_REF, type, gimple_call_arg (stmt, 0), ptr); references->safe_push (ref); @@ -4570,6 +4582,7 @@ get_references_in_stmt (gimple *stmt, ve { ref.ref = op1; ref.is_read = true; + ref.is_conditional_in_stmt = false; references->safe_push (ref); } } @@ -4583,6 +4596,7 @@ get_references_in_stmt (gimple *stmt, ve { ref.ref = op0; ref.is_read = false; + ref.is_conditional_in_stmt = false; references->safe_push (ref); } return clobbers_memory; @@ -4647,8 +4661,8 @@ find_data_references_in_stmt (struct loo FOR_EACH_VEC_ELT (references, i, ref) { - dr = create_data_ref (nest, loop_containing_stmt (stmt), - ref->ref, stmt, ref->is_read); + dr = create_data_ref (nest, loop_containing_stmt (stmt), ref->ref, + stmt, ref->is_read, ref->is_conditional_in_stmt); gcc_assert (dr != NULL); datarefs->safe_push (dr); } @@ -4677,7 +4691,8 @@ graphite_find_data_references_in_stmt (l FOR_EACH_VEC_ELT (references, i, ref) { - dr = create_data_ref (nest, loop, ref->ref, stmt, ref->is_read); + dr = create_data_ref (nest, loop, ref->ref, stmt, ref->is_read, + ref->is_conditional_in_stmt); gcc_assert (dr != NULL); datarefs->safe_push (dr); } Index: gcc/tree-ssa-loop-prefetch.c =================================================================== --- gcc/tree-ssa-loop-prefetch.c 2017-06-26 19:41:19.549571836 +0100 +++ gcc/tree-ssa-loop-prefetch.c 2017-06-28 14:26:24.025879789 +0100 @@ -1633,7 +1633,7 @@ determine_loop_nest_reuse (struct loop * for (ref = gr->refs; ref; ref = ref->next) { dr = create_data_ref (nest, loop_containing_stmt (ref->stmt), - ref->mem, ref->stmt, !ref->write_p); + ref->mem, ref->stmt, !ref->write_p, false); if (dr) { Index: gcc/tree-vect-data-refs.c =================================================================== --- gcc/tree-vect-data-refs.c 2017-06-28 14:26:19.652051284 +0100 +++ gcc/tree-vect-data-refs.c 2017-06-28 14:26:24.026879750 +0100 @@ -647,6 +647,67 @@ vect_slp_analyze_instance_dependence (sl return res; } +/* Record in VINFO that base address BASE_ADDR has alignment + BASE_ALIGNMENT. This information came from DR (which is useful + for recording in the dump file). */ + +void +vect_record_base_alignment (vec_info *vinfo, data_reference *dr, + tree base_addr, unsigned int base_alignment) +{ + bool existed; + unsigned int &entry + = vinfo->base_alignments.get_or_insert (base_addr, &existed); + if (!existed || entry < base_alignment) + { + entry = base_alignment; + if (dump_enabled_p ()) + { + dump_printf_loc (MSG_NOTE, vect_location, + "setting base alignment for "); + dump_generic_expr (MSG_NOTE, TDF_SLIM, base_addr); + dump_printf (MSG_NOTE, " to %d, based on ", base_alignment); + dump_gimple_stmt (MSG_NOTE, TDF_SLIM, DR_STMT (dr), 0); + } + } +} + +/* If the region we're going to vectorize is reached, all unconditional + data references occur at least once. We can therefore pool the base + alignment guarantees from each unconditional reference. Do this by + going through all the data references in VINFO and checking whether + the containing statement makes the reference unconditionally. If so, + record the alignment of the base address in VINFO so that it can be + used for all other references with the same base. */ + +void +vect_record_base_alignments (vec_info *vinfo) +{ + loop_vec_info loop_vinfo = dyn_cast (vinfo); + struct loop *loop = loop_vinfo ? LOOP_VINFO_LOOP (loop_vinfo) : NULL; + data_reference *dr; + unsigned int i; + FOR_EACH_VEC_ELT (vinfo->datarefs, i, dr) + if (!DR_IS_CONDITIONAL_IN_STMT (dr)) + { + vect_record_base_alignment (vinfo, dr, + DR_BASE_ADDRESS (dr), + DR_BASE_ALIGNMENT (dr)); + + /* If DR is nested in the loop that is being vectorized, we can also + record the alignment of the base wrt the outer loop. */ + gimple *stmt = DR_STMT (dr); + if (loop && nested_in_vect_loop_p (loop, DR_STMT (dr))) + { + stmt_vec_info stmt_info = vinfo_for_stmt (stmt); + vect_record_base_alignment + (vinfo, dr, + STMT_VINFO_DR_BASE_ADDRESS (stmt_info), + STMT_VINFO_DR_BASE_ALIGNMENT (stmt_info)); + } + } +} + /* Function vect_compute_data_ref_alignment Compute the misalignment of the data reference DR. @@ -664,6 +725,7 @@ vect_compute_data_ref_alignment (struct { gimple *stmt = DR_STMT (dr); stmt_vec_info stmt_info = vinfo_for_stmt (stmt); + vec_base_alignments *base_alignments = &stmt_info->vinfo->base_alignments; loop_vec_info loop_vinfo = STMT_VINFO_LOOP_VINFO (stmt_info); struct loop *loop = NULL; tree ref = DR_REF (dr); @@ -702,6 +764,9 @@ vect_compute_data_ref_alignment (struct { tree step = DR_STEP (dr); + aligned_to = STMT_VINFO_DR_ALIGNED_TO (stmt_info); + base_addr = STMT_VINFO_DR_BASE_ADDRESS (stmt_info); + base_alignment = STMT_VINFO_DR_BASE_ALIGNMENT (stmt_info); if (tree_fits_shwi_p (step) && tree_to_shwi (step) % GET_MODE_SIZE (TYPE_MODE (vectype)) == 0) { @@ -709,9 +774,6 @@ vect_compute_data_ref_alignment (struct dump_printf_loc (MSG_NOTE, vect_location, "inner step divides the vector-size.\n"); misalign = STMT_VINFO_DR_INIT (stmt_info); - aligned_to = STMT_VINFO_DR_ALIGNED_TO (stmt_info); - base_addr = STMT_VINFO_DR_BASE_ADDRESS (stmt_info); - base_alignment = STMT_VINFO_DR_BASE_ALIGNMENT (stmt_info); } else { @@ -742,6 +804,11 @@ vect_compute_data_ref_alignment (struct } } + /* Calculate the maximum of the pooled base address alignment and the + alignment that we can compute for DR itself. */ + if (unsigned int *entry = base_alignments->get (base_addr)) + base_alignment = MAX (base_alignment, *entry); + if (base_alignment >= TYPE_ALIGN (TREE_TYPE (vectype))) DR_VECT_AUX (dr)->base_element_aligned = true; @@ -2089,8 +2156,7 @@ vect_find_same_alignment_drs (struct dat if (dra == drb) return; - if (!operand_equal_p (DR_BASE_OBJECT (dra), DR_BASE_OBJECT (drb), - OEP_ADDRESS_OF) + if (!operand_equal_p (DR_BASE_ADDRESS (dra), DR_BASE_ADDRESS (drb), 0) || !operand_equal_p (DR_OFFSET (dra), DR_OFFSET (drb), 0) || !operand_equal_p (DR_STEP (dra), DR_STEP (drb), 0)) return; @@ -2148,6 +2214,7 @@ vect_analyze_data_refs_alignment (loop_v vec datarefs = vinfo->datarefs; struct data_reference *dr; + vect_record_base_alignments (vinfo); FOR_EACH_VEC_ELT (datarefs, i, dr) { stmt_vec_info stmt_info = vinfo_for_stmt (DR_STMT (dr)); @@ -3346,7 +3413,8 @@ vect_analyze_data_refs (vec_info *vinfo, { struct data_reference *newdr = create_data_ref (NULL, loop_containing_stmt (stmt), - DR_REF (dr), stmt, maybe_scatter ? false : true); + DR_REF (dr), stmt, !maybe_scatter, + DR_IS_CONDITIONAL_IN_STMT (dr)); gcc_assert (newdr != NULL && DR_REF (newdr)); if (DR_BASE_ADDRESS (newdr) && DR_OFFSET (newdr) Index: gcc/tree-vect-slp.c =================================================================== --- gcc/tree-vect-slp.c 2017-06-26 19:41:19.549571836 +0100 +++ gcc/tree-vect-slp.c 2017-06-28 14:26:24.027879710 +0100 @@ -2367,6 +2367,7 @@ new_bb_vec_info (gimple_stmt_iterator re gimple_stmt_iterator gsi; res = (bb_vec_info) xcalloc (1, sizeof (struct _bb_vec_info)); + new (&res->base_alignments) vec_base_alignments (); res->kind = vec_info::bb; BB_VINFO_BB (res) = bb; res->region_begin = region_begin; @@ -2741,6 +2742,8 @@ vect_slp_analyze_bb_1 (gimple_stmt_itera return NULL; } + vect_record_base_alignments (bb_vinfo); + /* Analyze and verify the alignment of data references and the dependence in the SLP instances. */ for (i = 0; BB_VINFO_SLP_INSTANCES (bb_vinfo).iterate (i, &instance); ) Index: gcc/tree-vect-loop.c =================================================================== --- gcc/tree-vect-loop.c 2017-06-26 19:41:19.549571836 +0100 +++ gcc/tree-vect-loop.c 2017-06-28 14:26:24.026879750 +0100 @@ -1157,6 +1157,7 @@ new_loop_vec_info (struct loop *loop) LOOP_VINFO_VECT_FACTOR (res) = 0; LOOP_VINFO_LOOP_NEST (res) = vNULL; LOOP_VINFO_DATAREFS (res) = vNULL; + new (&res->base_alignments) vec_base_alignments (); LOOP_VINFO_DDRS (res) = vNULL; LOOP_VINFO_UNALIGNED_DR (res) = NULL; LOOP_VINFO_MAY_MISALIGN_STMTS (res) = vNULL; Index: gcc/tree-vectorizer.c =================================================================== --- gcc/tree-vectorizer.c 2017-06-26 19:41:19.549571836 +0100 +++ gcc/tree-vectorizer.c 2017-06-28 14:26:24.027879710 +0100 @@ -370,6 +370,8 @@ vect_destroy_datarefs (vec_info *vinfo) } free_data_refs (vinfo->datarefs); + + vinfo->base_alignments.~vec_base_alignments (); } /* A helper function to free scev and LOOP niter information, as well as Index: gcc/testsuite/gcc.dg/vect/pr81136.c =================================================================== --- gcc/testsuite/gcc.dg/vect/pr81136.c 2017-06-28 14:25:58.810888422 +0100 +++ gcc/testsuite/gcc.dg/vect/pr81136.c 2017-06-28 14:26:24.024879829 +0100 @@ -14,3 +14,5 @@ fn1 (int n) for (int i = 0; i < n; i++) a->bar[i] = b[i]; } + +/* { dg-final { scan-tree-dump-not "Unknown misalignment" "vect" } } */