public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/111949] New: combine split points are not so good with targets that have (and (not x) y)
@ 2023-10-24  6:01 pinskia at gcc dot gnu.org
  2024-05-23  4:17 ` [Bug target/111949] " pinskia at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-10-24  6:01 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 111949
           Summary: combine split points are not so good with targets that
                    have (and (not x) y)
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: enhancement
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---
            Target: aarch64

Take:
```
bool f1(int a, bool b)
{
        int c = a & b;
        return (c ^ a)&1;
}
```
Currently GCC produces:
```
        and     w1, w1, 255
        bic     w0, w0, w1
        and     w0, w0, 1
```

Notice how there are 2 and.

If we look at combine dumps we will see:
Trying 3, 8 -> 10:
    3: r98:SI=zero_extend(x1:QI)
      REG_DEAD x1:QI
    8: r101:SI=~r98:SI&r103:SI
      REG_DEAD r98:SI
      REG_DEAD r103:SI
   10: r102:SI=r101:SI&0x1
      REG_DEAD r101:SI
Failed to match this instruction:
(set (reg:SI 102)
    (and:SI (and:SI (not:SI (reg:SI 1 x1 [ b ]))
            (reg:SI 103))
        (const_int 1 [0x1])))
Successfully matched this instruction:
(set (reg:SI 101)
    (not:SI (reg:SI 1 x1 [ b ])))
Failed to match this instruction:
(set (reg:SI 102)
    (and:SI (and:SI (reg:SI 101)
            (reg:SI 103))
        (const_int 1 [0x1])))

The first part is good but the second part is not so good and shows that
combine not finding a good split point and using:
(and:SI (not:SI (reg:SI 1 x1 [ b ])) (reg:SI 103))
as the point how to split the above instruction.

(note I don't know if this should be a generic change or a target specific one
off hand, just filing it to keep track of what missed optimization I found).

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

* [Bug target/111949] combine split points are not so good with targets that have (and (not x) y)
  2023-10-24  6:01 [Bug target/111949] New: combine split points are not so good with targets that have (and (not x) y) pinskia at gcc dot gnu.org
@ 2024-05-23  4:17 ` pinskia at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-05-23  4:17 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=115086
   Last reconfirmed|                            |2024-05-23
             Status|UNCONFIRMED                 |ASSIGNED
     Ever confirmed|0                           |1

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Mine. very similar to PR 115086, at least for:
```
int f1(int a, unsigned char b)
{
  int c = a & b;
  return (c ^ a)&1;
}
```

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

end of thread, other threads:[~2024-05-23  4:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-24  6:01 [Bug target/111949] New: combine split points are not so good with targets that have (and (not x) y) pinskia at gcc dot gnu.org
2024-05-23  4:17 ` [Bug target/111949] " 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).