[llvm] Riscv branch peephole opt (PR #90451)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 29 09:45:37 PDT 2024
topperc wrote:
> > Do you have an end-to-end C language example that will produce these instructions?
>
> The following is the minimal code which can produce the `bne a0, a0, %bb1` instruction. It's cropped from spec2006/400.perlbench/Base64.c/XS_MIME__QuotedPrint_encode_qp function which can produce `bne` instruction too.
>
> ```
> #define qp_isplain(c) ((c) == '\t' || (((c) >= ' ' && (c) <= '~') && (c) != '='))
> int test_bne(char *beg, char *end)
> {
> char *p;
> char *p_beg;
>
> p = beg;
> while (1) {
> p_beg = p;
>
> while (p < end && qp_isplain(*p)) {
> p++;
> }
> if (p == end || *p == '\n') {
> while (p > p_beg && (*(p - 1) == '\t' || *(p - 1) == ' '))
> p--;
> }
> }
> }
> ```
>
> Build command: `clang -S -fno-PIC -g -march=rv64imafdc_zba_zbb_zbc_zbs -mabi=lp64d -Ofast -o xxx.S xxx.c`
That compiles to an empty function on compiler explorer https://godbolt.org/z/ss3fqYTo4
https://github.com/llvm/llvm-project/pull/90451
More information about the llvm-commits
mailing list