public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/106146] New: [instcombine] a redundant movprfx insn compare to llvm
@ 2022-06-30 12:29 zhongyunde at huawei dot com
  2022-07-11 22:15 ` [Bug target/106146] " pinskia at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: zhongyunde at huawei dot com @ 2022-06-30 12:29 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 106146
           Summary: [instcombine] a redundant movprfx insn compare to llvm
           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, gcc has a redundant movprfx insn in the kernel loop body, see
detail https://gcc.godbolt.org/z/8vG4PzM18. 

```
#include <arm_sve.h>

#define ARRAY_ALIGNMENT 64
#define LEN_2D 128ll
#define LEN_1D 8000ll
#define iterations 10000
typedef float real_t;

__attribute__((aligned(ARRAY_ALIGNMENT))) real_t a[LEN_1D],b[LEN_1D];

void s113_tuned(void) {
    for (int nl = 0; nl < 4*iterations; nl++) {
        int64_t i = 1;
        svbool_t pg = svwhilelt_b32(i, LEN_1D);
        svfloat32_t a0v = svdup_f32(a[0]);
        do {
            svfloat32_t bv = svld1_f32(pg, &b[i]);
            svfloat32_t res = svadd_z(pg, bv, a0v);
            svst1(pg, &a[i], res);
            i += svcntw();
            pg = svwhilelt_b32(i, LEN_1D);
        } while (svptest_any(svptrue_b32(), pg));
    }
    return;
}
```

* gcc's kernel loop
```
.L2:
        ld1w    z0.s, p0/z, [x3, x0, lsl 2]
        movprfx z0.s, p0/z, z0.s
        fadd    z0.s, p0/m, z0.s, z1.s
        st1w    z0.s, p0, [x1, x0, lsl 2]
        incw    x0
        whilelt p0.s, x0, x2
        b.any   .L2
```

* llvm's kernel loop:
```
.LBB0_2:                                //   Parent Loop BB0_1 Depth=1
        ld1w    { z1.s }, p2/z, [x13, x14, lsl #2]
        fadd    z1.s, p2/m, z1.s, z0.s
        st1w    { z1.s }, p2, [x12, x14, lsl #2]
        add     x14, x10, x14
        whilelt p2.s, x14, x9
        b.ne    .LBB0_2
```

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

end of thread, other threads:[~2024-02-27 19:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-30 12:29 [Bug c/106146] New: [instcombine] a redundant movprfx insn compare to llvm zhongyunde at huawei dot com
2022-07-11 22:15 ` [Bug target/106146] " pinskia at gcc dot gnu.org
2022-07-11 22:23 ` pinskia at gcc dot gnu.org
2024-02-27 19:02 ` 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).