public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/98674] [10/11] Regression vectorizer failed for compilation time alias
Date: Thu, 14 Jan 2021 10:55:39 +0000	[thread overview]
Message-ID: <bug-98674-4-AQtvZANJeD@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-98674-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98674

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2021-01-14
                 CC|                            |rguenth at gcc dot gnu.org,
                   |                            |rsandifo at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
(compute_affine_dependence
  stmt_a: load_dst_23 = MEM[(short int *)p_21];
  stmt_b: *p_21 = _8;
) -> dependence analysis failed
x.c:1:6: missed:   versioning for alias required: can't determine dependence
between MEM[(short int *)p_21] and *p_21
consider run-time aliasing test between MEM[(short int *)p_21] and *p_21

so the issue is that dependence analysis fails.  A dependence distance of
zero would be OK.  Above we see two different base objects, one accesses
the ref as 'short int' and one as 'unsigned short int' (but with
short int alias type).  We're doing

  bool same_base_p = (full_seq.start_a + full_seq.length == num_dimensions_a
                      && full_seq.start_b + full_seq.length == num_dimensions_b
                      && DR_UNCONSTRAINED_BASE (a) == DR_UNCONSTRAINED_BASE (b)
                      && operand_equal_p (base_a, base_b, OEP_ADDRESS_OF)
                      && types_compatible_p (TREE_TYPE (base_a),
                                             TREE_TYPE (base_b))
                      && (!loop_nest.exists ()
                          || (object_address_invariant_in_loop_p
                              (loop_nest[0], base_a))));

and "fail" the types_compatible_p test which for non-aggregate types is
probably too strict and could be relaxed to at least consider
signed/unsigned type variants as the same.  Maybe for non-aggregate
types just compare the mode.

Richard, you refactored this code last?

For example

diff --git a/gcc/tree-data-ref.c b/gcc/tree-data-ref.c
index 394470af757..1853f4b4a07 100644
--- a/gcc/tree-data-ref.c
+++ b/gcc/tree-data-ref.c
@@ -3272,8 +3272,11 @@ initialize_data_dependence_relation (struct
data_reference *a,
                      && full_seq.start_b + full_seq.length == num_dimensions_b
                      && DR_UNCONSTRAINED_BASE (a) == DR_UNCONSTRAINED_BASE (b)
                      && operand_equal_p (base_a, base_b, OEP_ADDRESS_OF)
-                     && types_compatible_p (TREE_TYPE (base_a),
-                                            TREE_TYPE (base_b))
+                     && ((!AGGREGATE_TYPE_P (TREE_TYPE (base_a))
+                          && !AGGREGATE_TYPE_P (TREE_TYPE (base_b))
+                          && TYPE_MODE (TREE_TYPE (base_a)) == TYPE_MODE
(TREE_TYPE (base_b)))
+                         || types_compatible_p (TREE_TYPE (base_a),
+                                                TREE_TYPE (base_b)))
                      && (!loop_nest.exists ()
                          || (object_address_invariant_in_loop_p
                              (loop_nest[0], base_a))));

makes this vectorized but in the end the same_base_p check is supposed to
verify whether access functions generated are comparable.

  reply	other threads:[~2021-01-14 10:55 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-14 10:19 [Bug tree-optimization/98674] New: " crazylht at gmail dot com
2021-01-14 10:55 ` rguenth at gcc dot gnu.org [this message]
2021-01-14 12:50 ` [Bug tree-optimization/98674] " rguenth at gcc dot gnu.org
2021-01-14 13:19 ` [Bug tree-optimization/98674] [10/11 Regression] " rguenth at gcc dot gnu.org
2021-01-14 13:26 ` rguenth at gcc dot gnu.org
2021-01-14 13:27 ` rsandifo at gcc dot gnu.org
2021-01-14 13:38 ` rguenther at suse dot de
2021-01-14 15:14 ` cvs-commit at gcc dot gnu.org
2021-01-14 15:14 ` [Bug tree-optimization/98674] [10 " rguenth at gcc dot gnu.org
2021-01-14 15:14 ` rguenth at gcc dot gnu.org
2021-01-15  2:49 ` crazylht at gmail dot com
2021-01-15  7:56 ` rguenth at gcc dot gnu.org
2021-04-08 12:02 ` rguenth at gcc dot gnu.org
2021-05-04 12:31 ` rguenth at gcc dot gnu.org
2022-06-28 10:43 ` jakub at gcc dot gnu.org
2023-07-07  9:22 ` rguenth at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-98674-4-AQtvZANJeD@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).