[llvm] Riscv branch peephole opt (PR #90451)

Zhijin Zeng via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 29 04:59:04 PDT 2024


zengdage 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--;
            }
    }
}
```


https://github.com/llvm/llvm-project/pull/90451


More information about the llvm-commits mailing list