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

Zhijin Zeng via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 29 19:45:11 PDT 2024


zengdage wrote:

> clang -S -fno-PIC -g -march=rv64imafdc_zba_zbb_zbc_zbs -mabi=lp64d -Ofast -o xxx.S xxx.c

Sorry, these are 13 places in my local SPEC2006 perlbench. Build command:
`clang -c  -DSPEC_CPU -DNDEBUG -DPERL_CORE   -fno-pic  -DSPEC_CPU_LP64 -Wno-everything -DSPEC_CPU_LINUX_X64 -std=gnu89  -Ofast -march=rv64gc_zba_zbb_zbc_zbs -mabi=lp64d      xxx.c -o xxx.o`

A list of these instruction from the above build command.  If add `-mllvm -inline-threshold=3420 -mllvm -unroll-max-count=15` to build, I will get 21 places in my local SPEC2006 perlbench.
```
mg.c
MI:BEQ $x0, $x0, %bb.17

perlio.c
MI:BEQ $x0, $x0, %bb.18

pp_pack.c
MI:BGEU $x22, renamable $x22, %bb.73

regexec.c
MI:BEQ $x0, $x0, %bb.548
MI:BNE $x0, $x0, %bb.548
MI:BNE $x0, $x0, %bb.56
MI:BEQ $x0, $x0, %bb.102
MI:BEQ $x0, $x0, %bb.215
MI:BNE $x0, $x0, %bb.215

toke.c
MI:BLTU $x10, renamable $x10, %bb.1778

util.c
MI:BNE $x0, $x0, %bb.5

Base64.c
MI:BNE $x27, renamable $x27, %bb.33
```
And my llvm project based on  `93e69abfc77b0bd90f3669e36e510dd4f45aab14`, and I use the following commands to build it.
```
cmake -DLLVM_PARALLEL_LINK_JOBS=1 -DLLVM_TARGETS_TO_BUILD=RISCV -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS="clang;lld" -DCMAKE_INSTALL_PREFIX=/toolchain/gitlab_llvm_install/centos  -DLLVM_DEFAULT_TARGET_TRIPLE=riscv64-unknown-linux-gnu -DLLVM_USE_LINKER=gold -DLLVM_BINUTILS_INCDIR=/toolchain/gitlab_llvm_install/lto/install/include -G Ninja ../llvm
```

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


More information about the llvm-commits mailing list