public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/111252] New: LoongArch: Suboptimal code for (a & ~mask) | (b & mask) where mask is a constant with value ((1 << n) - 1) << m
@ 2023-08-31  4:31 xry111 at gcc dot gnu.org
  2023-08-31  4:33 ` [Bug target/111252] " xry111 at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: xry111 at gcc dot gnu.org @ 2023-08-31  4:31 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 111252
           Summary: LoongArch: Suboptimal code for (a & ~mask) | (b &
                    mask) where mask is a constant with value ((1 << n) -
                    1) << m
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: xry111 at gcc dot gnu.org
  Target Milestone: ---

int test(int a, int b)
{
  return (a & ~0x10) | (b & 0x10);
}

compiles to:

        addi.w  $r12,$r0,-17                    # 0xffffffffffffffef
        and     $r12,$r12,$r4
        andi    $r5,$r5,16
        or      $r12,$r12,$r5
        slli.w  $r4,$r12,0
        jr      $r1

It should be improved:

bstrpick.w $r4, $r4, 4, 4
bstrins.w  $r5, $r4, 4, 4
or         $r5, $r4, $r0

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

end of thread, other threads:[~2023-09-07  8:01 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-31  4:31 [Bug target/111252] New: LoongArch: Suboptimal code for (a & ~mask) | (b & mask) where mask is a constant with value ((1 << n) - 1) << m xry111 at gcc dot gnu.org
2023-08-31  4:33 ` [Bug target/111252] " xry111 at gcc dot gnu.org
2023-08-31  4:42 ` pinskia at gcc dot gnu.org
2023-08-31  4:44 ` xry111 at gcc dot gnu.org
2023-08-31  4:46 ` pinskia at gcc dot gnu.org
2023-08-31  4:53 ` xry111 at gcc dot gnu.org
2023-08-31  4:54 ` xry111 at gcc dot gnu.org
2023-09-07  7:59 ` cvs-commit at gcc dot gnu.org
2023-09-07  8:01 ` xry111 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).