public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/111149] New: bool0 != bool1 should be convert into bool0 ^ bool1
@ 2023-08-25  2:09 pinskia at gcc dot gnu.org
  2023-08-25  2:09 ` [Bug tree-optimization/111149] " pinskia at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-25  2:09 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 111149
           Summary: bool0 != bool1 should be convert into bool0 ^ bool1
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: enhancement
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---

Take:
```
_Bool k(_Bool a, _Bool b)
{
  return a != b;
}
```
This should be changed into:
```
_Bool k0(_Bool a, _Bool b)
{
  return a ^ b;
}
```

Note clange handles this.

The main problem with this is with respect to having it inside GIMPLE_COND ...

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

* [Bug tree-optimization/111149] bool0 != bool1 should be convert into bool0 ^ bool1
  2023-08-25  2:09 [Bug tree-optimization/111149] New: bool0 != bool1 should be convert into bool0 ^ bool1 pinskia at gcc dot gnu.org
@ 2023-08-25  2:09 ` pinskia at gcc dot gnu.org
  2023-08-25  2:21 ` [Bug middle-end/111149] bool0 != bool1 should be expanded as " pinskia at gcc dot gnu.org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-25  2:09 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |pinskia at gcc dot gnu.org
             Status|UNCONFIRMED                 |ASSIGNED
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2023-08-25

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

* [Bug middle-end/111149] bool0 != bool1 should be expanded as bool0 ^ bool1
  2023-08-25  2:09 [Bug tree-optimization/111149] New: bool0 != bool1 should be convert into bool0 ^ bool1 pinskia at gcc dot gnu.org
  2023-08-25  2:09 ` [Bug tree-optimization/111149] " pinskia at gcc dot gnu.org
@ 2023-08-25  2:21 ` pinskia at gcc dot gnu.org
  2023-08-29  4:24 ` [Bug tree-optimization/111149] " pinskia at gcc dot gnu.org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-25  2:21 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|tree-optimization           |middle-end
            Summary|bool0 != bool1 should be    |bool0 != bool1 should be
                   |convert into bool0 ^ bool1  |expanded as bool0 ^ bool1

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
So this is an expansion issue rather than a GIMPLE issue.

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

* [Bug tree-optimization/111149] bool0 != bool1 should be expanded as bool0 ^ bool1
  2023-08-25  2:09 [Bug tree-optimization/111149] New: bool0 != bool1 should be convert into bool0 ^ bool1 pinskia at gcc dot gnu.org
  2023-08-25  2:09 ` [Bug tree-optimization/111149] " pinskia at gcc dot gnu.org
  2023-08-25  2:21 ` [Bug middle-end/111149] bool0 != bool1 should be expanded as " pinskia at gcc dot gnu.org
@ 2023-08-29  4:24 ` pinskia at gcc dot gnu.org
  2023-08-29 17:14 ` pinskia at gcc dot gnu.org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-29  4:24 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|middle-end                  |tree-optimization

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I need to look into this again for the gimple level because I have noticed VRP
changes bool != bool into bool ^ bool but we should be able to do it without
VRP.

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

* [Bug tree-optimization/111149] bool0 != bool1 should be expanded as bool0 ^ bool1
  2023-08-25  2:09 [Bug tree-optimization/111149] New: bool0 != bool1 should be convert into bool0 ^ bool1 pinskia at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2023-08-29  4:24 ` [Bug tree-optimization/111149] " pinskia at gcc dot gnu.org
@ 2023-08-29 17:14 ` pinskia at gcc dot gnu.org
  2023-08-29 17:23 ` pinskia at gcc dot gnu.org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-29 17:14 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Just a few notes here.
canonicalize_cond_expr_cond does handle `a ^ b` .

gimple_cond_get_ops_from_tree/is_gimple_condexpr_1 does not but they do handle
TRUTH_NOT_EXPR which is shocking because that is only can come from fold ...

So forwprop and ifcombine all handle this correctly (since they use
canonicalize_cond_expr_cond) but others don't.

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

* [Bug tree-optimization/111149] bool0 != bool1 should be expanded as bool0 ^ bool1
  2023-08-25  2:09 [Bug tree-optimization/111149] New: bool0 != bool1 should be convert into bool0 ^ bool1 pinskia at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2023-08-29 17:14 ` pinskia at gcc dot gnu.org
@ 2023-08-29 17:23 ` pinskia at gcc dot gnu.org
  2023-08-30  0:15 ` pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-29 17:23 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This solve part of `bug 110637` too.

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

* [Bug tree-optimization/111149] bool0 != bool1 should be expanded as bool0 ^ bool1
  2023-08-25  2:09 [Bug tree-optimization/111149] New: bool0 != bool1 should be convert into bool0 ^ bool1 pinskia at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2023-08-29 17:23 ` pinskia at gcc dot gnu.org
@ 2023-08-30  0:15 ` pinskia at gcc dot gnu.org
  2023-08-30  5:07 ` pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-30  0:15 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
So implementing this breaks forwprop ...
Which I kinda of expected.

But we can do the canonicalization inside fold_stmt_1 and that works better.

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

* [Bug tree-optimization/111149] bool0 != bool1 should be expanded as bool0 ^ bool1
  2023-08-25  2:09 [Bug tree-optimization/111149] New: bool0 != bool1 should be convert into bool0 ^ bool1 pinskia at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2023-08-30  0:15 ` pinskia at gcc dot gnu.org
@ 2023-08-30  5:07 ` pinskia at gcc dot gnu.org
  2023-08-30  5:13 ` pinskia at gcc dot gnu.org
  2023-08-30  6:11 ` pinskia at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-30  5:07 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
So g++.dg/vect/simd-bool-comparison-1.cc fails with the canonicalization ...
Looking into how to fix that too.

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

* [Bug tree-optimization/111149] bool0 != bool1 should be expanded as bool0 ^ bool1
  2023-08-25  2:09 [Bug tree-optimization/111149] New: bool0 != bool1 should be convert into bool0 ^ bool1 pinskia at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2023-08-30  5:07 ` pinskia at gcc dot gnu.org
@ 2023-08-30  5:13 ` pinskia at gcc dot gnu.org
  2023-08-30  6:11 ` pinskia at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-30  5:13 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #6)
> So g++.dg/vect/simd-bool-comparison-1.cc fails with the canonicalization ...
> Looking into how to fix that too.

The difference is:
  _3 = _1 ^ c.0_2;
  cstore_10 = _3 ? 0.0 : 1.0e+0;


vs:
  _3 = _1 != c.0_2;
  cstore_10 = _3 ? 0.0 : 1.0e+0;


Original:
/app/example.cpp:12:17: note:   === vect_determine_precisions ===
/app/example.cpp:12:17: note:   using boolean precision 8 for _3 = _1 != c.0_2;

New:
t.cc:14:17: note:   === vect_determine_precisions ===
t.cc:14:17: note:   using normal nonmask vectors for _3 = _1 ^ c.0_2;

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

* [Bug tree-optimization/111149] bool0 != bool1 should be expanded as bool0 ^ bool1
  2023-08-25  2:09 [Bug tree-optimization/111149] New: bool0 != bool1 should be convert into bool0 ^ bool1 pinskia at gcc dot gnu.org
                   ` (7 preceding siblings ...)
  2023-08-30  5:13 ` pinskia at gcc dot gnu.org
@ 2023-08-30  6:11 ` pinskia at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-30  6:11 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Created attachment 55815
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55815&action=edit
What I have so far

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

end of thread, other threads:[~2023-08-30  6:11 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-25  2:09 [Bug tree-optimization/111149] New: bool0 != bool1 should be convert into bool0 ^ bool1 pinskia at gcc dot gnu.org
2023-08-25  2:09 ` [Bug tree-optimization/111149] " pinskia at gcc dot gnu.org
2023-08-25  2:21 ` [Bug middle-end/111149] bool0 != bool1 should be expanded as " pinskia at gcc dot gnu.org
2023-08-29  4:24 ` [Bug tree-optimization/111149] " pinskia at gcc dot gnu.org
2023-08-29 17:14 ` pinskia at gcc dot gnu.org
2023-08-29 17:23 ` pinskia at gcc dot gnu.org
2023-08-30  0:15 ` pinskia at gcc dot gnu.org
2023-08-30  5:07 ` pinskia at gcc dot gnu.org
2023-08-30  5:13 ` pinskia at gcc dot gnu.org
2023-08-30  6:11 ` pinskia 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).