Open GabrielRavier opened 1 month ago
#include <stdint.h> uint8_t f(uint8_t x) { return (x == 0) ? -1 : 0; }
With -O3, GCC outputs the following:
-O3
f(unsigned char): addic 3,3,-1 subfe 3,3,3 rlwinm 3,3,0,0xff blr
whereas LLVM outputs this:
f(unsigned char): # @f(unsigned char) cntlzw 3, 3 srwi 3, 3, 5 neg 3, 3 clrlwi 3, 3, 24 blr
...and GCC's sequence is 30-50% faster according to llvm-mca.
llvm-mca
@llvm/issue-subscribers-backend-powerpc
Author: Gabriel Ravier (GabrielRavier)
On -mcpu=pwr8 or newer, output codegen uses isel:
-mcpu=pwr8
cmpwi 3, 0 li 3, 0 li 4, 255 iseleq 3, 4, 3 blr
With
-O3
, GCC outputs the following:whereas LLVM outputs this:
...and GCC's sequence is 30-50% faster according to
llvm-mca
.