public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/114045] New: large _BitInt * _Bool (or having known boolean range) should be inlined instead of calling __mulbitint3
@ 2024-02-22  8:36 pinskia at gcc dot gnu.org
  2024-02-22  8:53 ` [Bug tree-optimization/114045] " jakub at gcc dot gnu.org
  2024-02-22  8:54 ` jakub at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-02-22  8:36 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 114045
           Summary: large _BitInt * _Bool (or having known boolean range)
                    should be inlined instead of calling __mulbitint3
           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:
```
unsigned _BitInt(1024) 
foo (unsigned _BitInt(1024) ub1024_0, _Bool b)
{
  unsigned _BitInt(1024) t  = ub1024_0 * b;
  return t;
}

unsigned _BitInt(1024) 
foo2 (unsigned _BitInt(1024) ub1024_0 , _Bool b)
{
  unsigned _BitInt(1024) t = (unsigned _BitInt(1024))b;
  return ub1024_0 & -t;
}

unsigned _BitInt(1024) 
foo1 (unsigned _BitInt(1024) ub1024_0 , _Bool b)
{
  if (b)
    return ub1024_0;
  else
    return 0;
}
```

These should be both optimized the same.
One thing I noticed also is the copy loop for the return not optimized to just
memcpy but that is for a different issue.

Noticed when looking into PR 114040.

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

* [Bug tree-optimization/114045] large _BitInt * _Bool (or having known boolean range) should be inlined instead of calling __mulbitint3
  2024-02-22  8:36 [Bug tree-optimization/114045] New: large _BitInt * _Bool (or having known boolean range) should be inlined instead of calling __mulbitint3 pinskia at gcc dot gnu.org
@ 2024-02-22  8:53 ` jakub at gcc dot gnu.org
  2024-02-22  8:54 ` jakub at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-02-22  8:53 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
If it is really that beneficial, some optimization before bitint lowering
should lower it, dealing with such special cases in bitint lowering would
quickly make it unmaintainable, it is already quite complex on its own.
Note, even the multiplication isn't that expensive, we pass to the library that
one of the arguments has 1-bit unsigned precision (or the library could figure
it out if we don't see the range in the source), so it shouldn't be doing full
16 x 16 limb multiplication...

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

* [Bug tree-optimization/114045] large _BitInt * _Bool (or having known boolean range) should be inlined instead of calling __mulbitint3
  2024-02-22  8:36 [Bug tree-optimization/114045] New: large _BitInt * _Bool (or having known boolean range) should be inlined instead of calling __mulbitint3 pinskia at gcc dot gnu.org
  2024-02-22  8:53 ` [Bug tree-optimization/114045] " jakub at gcc dot gnu.org
@ 2024-02-22  8:54 ` jakub at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-02-22  8:54 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
And, as for loops, we pattern recognize loops doing memcpy, memset, memmove
etc. later on.

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

end of thread, other threads:[~2024-02-22  8:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-22  8:36 [Bug tree-optimization/114045] New: large _BitInt * _Bool (or having known boolean range) should be inlined instead of calling __mulbitint3 pinskia at gcc dot gnu.org
2024-02-22  8:53 ` [Bug tree-optimization/114045] " jakub at gcc dot gnu.org
2024-02-22  8:54 ` jakub 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).