Issue 97884
Summary [AArch64] Special optimazation for sdiv 2
Labels new issue
Assignees vfdff
Reporter vfdff
    * test: https://gcc.godbolt.org/z/j4EqrToT7
```
int foo_int2 (int diff) {
 diff = diff  / 2;
   return diff;
}
```
> When I take a look at the issue [PR97821](https://github.com/llvm/llvm-project/issues/97821), I find gcc has some special addressing for **sdiv 2**, so we can also enhance this case.

* **gcc**: 2 instructions
```
foo_int2:
 add     w0, w0, w0, lsr 31
        asr     w0, w0, 1
 ret
```

* **llvm**: 3 instructions
```
foo_int2: // @foo_int2
        cmp     w0, #0
        cinc w8, w0, lt
        asr     w0, w8, #1
        ret
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to