Skip to content

cmd/compile: OpAMD64CMOV*EQF clobbers AX, doesn't tell regalloc #26097

@heschi

Description

@heschi

CL 98695 (commit 080187f) adds OpAMD64CMOV{Q,L,W}EQF. The generated assembly looks like:

// MOV SRC,AX
// CMOV*NE DST,AX
// CMOV*PC AX,DST

That is, it uses AX as a scratch register so that it can check both equality and NAN-ness. (I think.) The problem is, regalloc doesn't know about this:
{name: "CMOVLEQF", argLength: 3, reg: gp21, asm: "CMOVLNE", resultInArg0: true},

gp21 doesn't have clobbers:ax.

I don't have a public repro, but given the below assembly I'm pretty sure I'm in the neighborhood of the problem. The three MOVLs clearly don't make sense.

 v677  	00341 (287)	UCOMISD	X1, X0
 v292  	00342 (287)	MOVL	$2, AX
 v287  	00343 (287)	MOVL	$1, CX
 v456  	00344 (287)	MOVL	CX, AX
 v456  	00345 (287)	CMOVLNE	AX, AX
 v456  	00346 (287)	CMOVLPC	AX, AX
 v460  	00347 (287)	MOVL	AX, "".~r2+24(SP)
 b196  	00348 (35)	RET

cc @randall77 @TocarIP @rasky

This is Google-internal b/110810807.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions