public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/110795] New: Bad code gen for vector compare booleans
@ 2023-07-24 22:20 munroesj at gcc dot gnu.org
  2023-07-24 22:25 ` [Bug target/110795] " munroesj at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: munroesj at gcc dot gnu.org @ 2023-07-24 22:20 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 110795
           Summary: Bad code gen for vector compare booleans
           Product: gcc
           Version: 13.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: munroesj at gcc dot gnu.org
  Target Milestone: ---

Created attachment 55626
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55626&action=edit
Test examples for vector code combinining vector compare combined with logical
or,

Combining a vec_cmplt and vec_cmpge with vector logical OR misscompiles.
For example:
  // Capture the carry t as a bool using signed compare
  t = vec_cmplt ((vi32_t) x, zeros);
  ge = vec_cmpge (x, z);
  // Combine t with (x >= z) for 33-bit compare
  t  = vec_or (ge, t);

This seems to work for the minimized example above but fails when used in the
more complex loop of the example vec_divduw_V1. At -O3 the compiler elides any
code generated for vec_cmplt.

With this bug the function vec_divduw_V1 (Vector_Divide double (words by)
unsigned word) fails the unit test.

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

* [Bug target/110795] Bad code gen for vector compare booleans
  2023-07-24 22:20 [Bug c/110795] New: Bad code gen for vector compare booleans munroesj at gcc dot gnu.org
@ 2023-07-24 22:25 ` munroesj at gcc dot gnu.org
  2023-07-24 22:31 ` munroesj at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: munroesj at gcc dot gnu.org @ 2023-07-24 22:25 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Steven Munroe <munroesj at gcc dot gnu.org> ---
Created attachment 55627
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55627&action=edit
Main and unit-test. When compiled and linked with vec_divide.c will verify if
the divide code is correct or not.

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

* [Bug target/110795] Bad code gen for vector compare booleans
  2023-07-24 22:20 [Bug c/110795] New: Bad code gen for vector compare booleans munroesj at gcc dot gnu.org
  2023-07-24 22:25 ` [Bug target/110795] " munroesj at gcc dot gnu.org
@ 2023-07-24 22:31 ` munroesj at gcc dot gnu.org
  2023-07-27  2:52 ` linkw at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: munroesj at gcc dot gnu.org @ 2023-07-24 22:31 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Steven Munroe <munroesj at gcc dot gnu.org> ---
Also fails with gcc11/12. Also fails with Advance Toolchain 10.0 GCC 6.4.1.

It might fail for all version between GCC 6 and 13.

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

* [Bug target/110795] Bad code gen for vector compare booleans
  2023-07-24 22:20 [Bug c/110795] New: Bad code gen for vector compare booleans munroesj at gcc dot gnu.org
  2023-07-24 22:25 ` [Bug target/110795] " munroesj at gcc dot gnu.org
  2023-07-24 22:31 ` munroesj at gcc dot gnu.org
@ 2023-07-27  2:52 ` linkw at gcc dot gnu.org
  2023-07-27  6:57 ` linkw at gcc dot gnu.org
  2023-07-28 14:42 ` munroesj at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: linkw at gcc dot gnu.org @ 2023-07-27  2:52 UTC (permalink / raw)
  To: gcc-bugs

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

Kewen Lin <linkw at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |linkw at gcc dot gnu.org
   Last reconfirmed|                            |2023-07-27
     Ever confirmed|0                           |1

--- Comment #3 from Kewen Lin <linkw at gcc dot gnu.org> ---
I'll have a look first.

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

* [Bug target/110795] Bad code gen for vector compare booleans
  2023-07-24 22:20 [Bug c/110795] New: Bad code gen for vector compare booleans munroesj at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2023-07-27  2:52 ` linkw at gcc dot gnu.org
@ 2023-07-27  6:57 ` linkw at gcc dot gnu.org
  2023-07-28 14:42 ` munroesj at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: linkw at gcc dot gnu.org @ 2023-07-27  6:57 UTC (permalink / raw)
  To: gcc-bugs

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

Kewen Lin <linkw at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |INVALID
             Status|ASSIGNED                    |RESOLVED

--- Comment #4 from Kewen Lin <linkw at gcc dot gnu.org> ---
I think this is a test case issue, with the below patch to the provided test
case, it can pass the associate testing:

$ diff -Nuar vec_divide.c.orig vec_divide.c
--- vec_divide.c.orig   2023-07-27 01:42:20.723440140 -0500
+++ vec_divide.c        2023-07-27 01:42:33.383375622 -0500
@@ -113,7 +113,7 @@
       // Then  the compiler should merge the NOT with OR as ORC
       ge = vec_cmpge (x, z);
       // Combine t with (x >= z) for 33-bit compare
-      t  = vec_or (ge, t);
+      ge  = vec_or (ge, t);

       /* if (x >= z) x = x - z ; y++ */
       xt = vec_sub (x, z);


It tries to "deconstruct ((t || x) >= z) as (t || (x >= z))", but adopts *ge*
rather than *t* as the selector for the following vec_sel, it's unexpected and
the testing passed once it gets fixed. I also tried with -O2 and -Ofast with
-mcpu=power10, all passed.

Please reopen it if the above is just a typo and the underlying issue is
covered.

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

* [Bug target/110795] Bad code gen for vector compare booleans
  2023-07-24 22:20 [Bug c/110795] New: Bad code gen for vector compare booleans munroesj at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2023-07-27  6:57 ` linkw at gcc dot gnu.org
@ 2023-07-28 14:42 ` munroesj at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: munroesj at gcc dot gnu.org @ 2023-07-28 14:42 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Steven Munroe <munroesj at gcc dot gnu.org> ---
Thanks, sorry I missed the obvious.

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

end of thread, other threads:[~2023-07-28 14:42 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-24 22:20 [Bug c/110795] New: Bad code gen for vector compare booleans munroesj at gcc dot gnu.org
2023-07-24 22:25 ` [Bug target/110795] " munroesj at gcc dot gnu.org
2023-07-24 22:31 ` munroesj at gcc dot gnu.org
2023-07-27  2:52 ` linkw at gcc dot gnu.org
2023-07-27  6:57 ` linkw at gcc dot gnu.org
2023-07-28 14:42 ` munroesj 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).