public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/107090] New: [aarch64] sequence logic should be combined with mul and umulh
@ 2022-09-29 17:51 zhongyunde at huawei dot com
  2022-09-29 17:55 ` [Bug middle-end/107090] " pinskia at gcc dot gnu.org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: zhongyunde at huawei dot com @ 2022-09-29 17:51 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 107090
           Summary: [aarch64] sequence logic should be combined with mul
                    and umulh
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zhongyunde at huawei dot com
  Target Milestone: ---

* test case: https://godbolt.org/z/x5jMhqW8s
```
#  define BN_BITS4        32
#  define BN_MASK2        (0xffffffffffffffffL)
#  define BN_MASK2l       (0xffffffffL)
#  define BN_MASK2h       (0xffffffff00000000L)
#  define BN_MASK2h1      (0xffffffff80000000L)
#  define LBITS(a)        ((a)&BN_MASK2l)
#  define HBITS(a)        (((a)>>BN_BITS4)&BN_MASK2l)
#  define L2HBITS(a)      (((a)<<BN_BITS4)&BN_MASK2)

void mul64(unsigned long in0, unsigned long in1,
           unsigned long &l, unsigned long &h) {
    unsigned long m, m1, lt, ht, bl, bh;
    lt = LBITS(in0);
    ht = HBITS(in0);
    bl = LBITS(in1);
    bh = HBITS(in1);
    m  = bh * lt;
    lt = bl * lt;
    m1 = bl * ht;
    ht = bh * ht;
    m  = (m + m1) & BN_MASK2;
    if (m < m1) ht += L2HBITS((unsigned long)1);
    ht += HBITS(m);
    m1 = L2HBITS(m);
    lt = (lt + m1) & BN_MASK2; if (lt < m1) ht++;
    l  = lt;
    h  = ht;
}
```
* The above source is equel to an mull operater for two 64bits integer vaules,
so it should be fold to similar assemble
```
   mul   x8,x1,x0
   umulh x9,x0,x1
   str   x8,[x2]
   str   x9,[x3]
   ret
```

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

end of thread, other threads:[~2022-10-29  1:54 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-29 17:51 [Bug c/107090] New: [aarch64] sequence logic should be combined with mul and umulh zhongyunde at huawei dot com
2022-09-29 17:55 ` [Bug middle-end/107090] " pinskia at gcc dot gnu.org
2022-09-29 21:32 ` [Bug tree-optimization/107090] " pinskia at gcc dot gnu.org
2022-10-01 23:42 ` zhongyunde at huawei dot com
2022-10-01 23:51 ` pinskia at gcc dot gnu.org
2022-10-07  9:44 ` zhongyunde at huawei dot com
2022-10-10  4:22 ` zhongyunde at huawei dot com
2022-10-10  4:30 ` pinskia at gcc dot gnu.org
2022-10-10  9:49 ` zhongyunde at huawei dot com
2022-10-12 13:36 ` zhongyunde at huawei dot com
2022-10-12 21:33 ` pinskia at gcc dot gnu.org
2022-10-13  2:57 ` zhongyunde at huawei dot com
2022-10-29  1:54 ` zhongyunde at huawei dot com

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).