Issue 80275
Summary [PRE] reuse the value to avoid double loading
Labels new issue
Assignees
Reporter vfdff
    * test: https://gcc.godbolt.org/z/7eKGbndfK
```
void foo(dComplex* __restrict__ bb, bool flag) {
	*aa = *bb;
    //memcpy(aa, bb, sizeof(dComplex));
    if (flag) 
    {
        *aa = aa->conj();
        // bb->neg();
    }
}

void foo1(dComplex* __restrict__ bb, bool flag) {
    aa->real = bb->real; aa->imag = bb->imag;
    if (flag) 
    {
        *aa = aa->conj();
    }
}
```

* llvm of **foo**: ldr often has large cost because of long latency, so reuse of the part value of q0 will be more efficient, which is similar to **foo1**
```
foo(dComplex*, bool):                      // @foo(dComplex*, bool)
        adrp    x8, aa
        ldr     q0, [x0]
        ldr     x8, [x8, :lo12:aa]
        str     q0, [x8]
        tbz     w1, #0, .LBB0_2
        ldr     d0, [x8, #8]       --- expect reuse the result of q0 (d0 is low part of q0)
        fneg    d0, d0
        str     d0, [x8, #8]
.LBB0_2:
        ret
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to