https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124023
Bug ID: 124023
Summary: Rewrite expresions to reduce dependency height and
unlock sinking
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: law at gcc dot gnu.org
Target Milestone: ---
Consider this from 531.deepsjeng, rv64gcbv_zicond:
typedef unsigned long long BITBOARD;
typedef int move_s;
struct state_t {
BITBOARD BlackPieces, WhitePieces;
BITBOARD pawnhash;
};
typedef struct state_t state_t;
extern BITBOARD zobrist[14][64];
void make(state_t * const s, const move_s move, int captured, BITBOARD M, int
target, int ep) {
if ((((captured)+1)&1) == 0) {
s->WhitePieces ^= M;
}
if ((((captured)+1)>>1) == 1) {
((s)->pawnhash ^= zobrist[(captured)][(target)]);
}
return;
}
Compiles into:
addiw a5,a2,1
andi a1,a5,1
bne a1,zero,.L2
ld a1,8(a0)
xor a3,a1,a3
sd a3,8(a0)
.L2:
sraiw a5,a5,1
li a3,1
beq a5,a3,.L5
ret
We could rewrite this so that the andi uses a2 as its source and invert the
conditional. That reduces the height of the dependency tree and may also allow
the addiw to sink.