llvm / llvm/llvm-project

[Mips] Missing BC1EQZ/BC1NEZ selection for floating-point branches on R6

Open
#224,541 1 comment 0 reactions 1 assignee Claimed by @FlyGoat View on GitHub
backend:MIPS missed-optimization
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

LLVM transfers floating-point comparison results into a GPR and uses an integer branch, although R6 provides instructions to branch directly on the FPR result.

### Reproducer

```llvm
declare void @on_true()
declare void @on_false()

define void @branch_fp(float %a, float %b) {
%cond = fcmp oeq float %a, %b
br i1 %cond, label %t, label %f

t:
call void @on_true()
ret void

f:
call void @on_false()
ret void
}
```

```sh
llc -mtriple=mipsel-linux-gnu -mcpu=mips32r6 -O2 \
-verify-machineinstrs repro.ll -o -
```

### Actual output
```asm
cmp.eq.s $f0, $f12, $f14
mfc1 $1, $f0
not $1, $1
andi $1, $1, 1
bnezc $1, $BB0_2
nop
```

### Expected output
```asm
cmp.eq.s $f0, $f12, $f14
bc1eqz $f0, $BB0_2
nop
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.