https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116615
Palmer Dabbelt <palmer at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |palmer at gcc dot gnu.org
--- Comment #2 from Palmer Dabbelt <palmer at gcc dot gnu.org> ---
I didn't remember what this means, which probably means I'd never looked at it
before, which probably means it just predates me working on this stuff. Andrew
might remember, but looks like MIPS has it defined as 0 and IIRC a lot of the
early port is MIPS-ish (though I think we pulled in a bunch of arm64 at some
point, so not 100% sure there).
So I'd bet this is just an oversight. That said, from reading the docs I can't
quite figure out what's going on -- I'd expect
long foo(long a, long b, long c, long d)
{
return a || b || c || d;
}
to generate something branchy, but it looks fine under -O1. I do get very
branchy code under -O0:
foo:
.LFB0:
.cfi_startproc
addi sp,sp,-48
.cfi_def_cfa_offset 48
sd ra,40(sp)
sd s0,32(sp)
.cfi_offset 1, -8
.cfi_offset 8, -16
addi s0,sp,48
.cfi_def_cfa 8, 0
sd a0,-24(s0)
sd a1,-32(s0)
sd a2,-40(s0)
sd a3,-48(s0)
ld a5,-24(s0)
bne a5,zero,.L2
ld a5,-32(s0)
bne a5,zero,.L2
ld a5,-40(s0)
bne a5,zero,.L2
ld a5,-48(s0)
beq a5,zero,.L3
.L2:
li a5,1
j .L4
.L3:
li a5,0
.L4:
mv a0,a5
ld ra,40(sp)
.cfi_restore 1
ld s0,32(sp)
.cfi_restore 8
.cfi_def_cfa 2, 48
addi sp,sp,48
.cfi_def_cfa_offset 0
jr ra
.cfi_endproc
so is some other optimization just eating the branches and re-optimizing for us
here? I'm getting basically the same thing with
LOGICAL_OP_NON_SHORT_CIRCUIT=1, so I'm kind of worried I'm just
misunderstanding the docs here.