public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/98674] New: [10/11] Regression vectorizer failed for compilation time alias
@ 2021-01-14 10:19 crazylht at gmail dot com
  2021-01-14 10:55 ` [Bug tree-optimization/98674] " rguenth at gcc dot gnu.org
                   ` (14 more replies)
  0 siblings, 15 replies; 16+ messages in thread
From: crazylht at gmail dot com @ 2021-01-14 10:19 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 98674
           Summary: [10/11] Regression vectorizer failed for compilation
                    time alias
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: crazylht at gmail dot com
  Target Milestone: ---
              Host: x86_64-pc-linux-gnu

Cat test.c, refer to https://godbolt.org/z/fx9cMq
---
void swap(short *p, int cnt) {
    cnt = 1000;
    while (cnt-- > 0) {
        *p = ((*p << 8) & 0xFF00) |
             ((*p >> 8) & 0x00FF);
        ++p;
    }
}
----


test.c:3:16: missed: couldn't vectorize loop
test.c:4:8: missed: not vectorized: compilation time alias: load_dst_23 =
MEM[(short int *)p_21];
*p_21 = _8;

but they have the same address, and of course they alias.

---
  <bb 3> [local count: 1063004409]:
  # p_21 = PHI <p_16(5), p_12(D)(2)>
  # cnt_24 = PHI <cnt_14(5), 999(2)>
  # ivtmp_26 = PHI <ivtmp_2(5), 1000(2)>
  load_dst_23 = MEM[(short int *)p_21];
  bswapdst_11 = load_dst_23 r>> 8;
  _8 = (short int) bswapdst_11;
  *p_21 = _8;
  p_16 = p_21 + 2;
  cnt_14 = cnt_24 + -1;
  ivtmp_2 = ivtmp_26 - 1;
  if (ivtmp_2 != 0)
----

So does vectorizer assume there won't be 2 DRs with same reference?

Successfully vectorized with below hack
---
modified   gcc/tree-vect-data-refs.c
@@ -3302,6 +3302,10 @@ vect_compile_time_alias (dr_vec_info *a, dr_vec_info *b,
   const_length_a += access_size_a;
   const_length_b += access_size_b;

+  /* It's ok for the same reference.  */
+  if (known_eq (const_length_a, const_length_b))
+    return 0;
+
   if (ranges_known_overlap_p (offset_a, const_length_a,
                              offset_b, const_length_b))
     return 1;

---

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2023-07-07  9:22 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-14 10:19 [Bug tree-optimization/98674] New: [10/11] Regression vectorizer failed for compilation time alias crazylht at gmail dot com
2021-01-14 10:55 ` [Bug tree-optimization/98674] " rguenth at gcc dot gnu.org
2021-01-14 12:50 ` 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

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).