G_BITREVERSE is generated from llvm.bitreverse.<type> intrinsics, clang
genrates these intrinsics from builtin_bitreverse32 and
builtin_bitreverse64.
Add lower and narrowscalar for G_BITREVERSE.
Lower G_BITREVERSE on MIPS32.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
When I apply this one and D71362 to the master branch I get a couple of failed tests:
LLVM :: CodeGen/Mips/GlobalISel/legalizer/bitreverse.mir LLVM :: CodeGen/Mips/GlobalISel/llvm-ir/bitreverse.ll
Should I apply any other patches before?
This patch needs only bswap, I just checked and it worked fine for me, what was the error?
I'll check again on my side tomorrow.
******************** TEST 'LLVM :: CodeGen/Mips/GlobalISel/llvm-ir/bitreverse.ll' FAILED ******************** Script: -- : 'RUN: at line 2'; /home/simon/work/llvm/bld/bin/llc -O0 -mtriple=mipsel-linux-gnu -global-isel -verify-machineinstrs /home/simon/work/llvm/git/llvm/test/CodeGen/Mips/GlobalISel/llvm-ir/bitreverse.ll -o -| /home/simon/work/llvm/bld/bin/FileCheck /home/simon/work/llvm/git/llvm/test/CodeGen/Mips/GlobalISel/llvm-ir/bitreverse.ll -check-prefixes=MIPS32 : 'RUN: at line 3'; /home/simon/work/llvm/bld/bin/llc -O0 -mtriple=mipsel-linux-gnu -global-isel -mattr=+mips32r2 -verify-machineinstrs /home/simon/work/llvm/git/llvm/test/CodeGen/Mips/GlobalISel/llvm-ir/bitreverse.ll -o -| /home/simon/work/llvm/bld/bin/FileCheck /home/simon/work/llvm/git/llvm/test/CodeGen/Mips/GlobalISel/llvm-ir/bitreverse.ll -check-prefixes=MIPS32R2 -- Exit Code: 1 Command Output (stderr): -- /home/simon/work/llvm/git/llvm/test/CodeGen/Mips/GlobalISel/llvm-ir/bitreverse.ll:20:16: error: MIPS32-NEXT: expected string not found in input ; MIPS32-NEXT: sll $3, $1, 4 ^ <stdin>:34:2: note: scanning from here and $3, $1, $2 ^ <stdin>:36:2: note: possible intended match here sll $1, $1, 4 ^ /home/simon/work/llvm/git/llvm/test/CodeGen/Mips/GlobalISel/llvm-ir/bitreverse.ll:89:16: error: MIPS32-NEXT: expected string not found in input ; MIPS32-NEXT: sll $3, $1, 4 ^ <stdin>:89:2: note: scanning from here and $3, $1, $2 ^ <stdin>:91:2: note: possible intended match here sll $1, $1, 4 ^
This change broke buildbots: http://lab.llvm.org:8011/builders/clang-x86_64-debian-fast/builds/21066.
I reverted it in 32cc14100e802fddd9f88e7a862250ce3108a583. Please always run ninja check-all before pushing.
Buildbot failures depend on compiler used to build clang.
Problem was in order which new MachineInstructions get inserted into MachineFunction.
Generated assembler does the same thing, but regression tests require consistent behavior regardless of compiler used.
In:
return B.buildOr(Dst, B.buildLShr(Ty, B.buildAnd(Ty, Src, MaskLoNTo0), C_N), B.buildAnd(Ty, B.buildShl(Ty, Src, C_N), MaskLoNTo0));
it is important which method was executed first since they insert MachineInstructions into MachineFunction. Order of execution:
gcc
B.buildAnd(Ty, B.buildShl(Ty, Src, C_N), MaskLoNTo0) B.buildLShr(Ty, B.buildAnd(Ty, Src, MaskLoNTo0), C_N)
clang
B.buildLShr(Ty, B.buildAnd(Ty, Src, MaskLoNTo0), C_N) B.buildAnd(Ty, B.buildShl(Ty, Src, C_N), MaskLoNTo0)
recommit notes:
Introduce temporary variables in order to make sure instructions get inserted into MachineFunction in same order regardless of compiler used to build llvm.