Fix incorrect conditions

This commit is contained in:
Dmitry Stogov 2022-12-01 00:43:42 +03:00
parent 25ab83e5a3
commit daf659a457
7 changed files with 10 additions and 10 deletions

View File

@ -2257,16 +2257,16 @@ static void ir_emit_min_max_int(ir_ctx *ctx, ir_ref def, ir_insn *insn)
| ASM_REG_REG_OP cmp, type, def_reg, op2_reg
if (insn->op == IR_MIN) {
if (IR_IS_TYPE_SIGNED(type)) {
| ASM_REG_REG_OP2 cmovl, type, def_reg, op2_reg
| ASM_REG_REG_OP2 cmovg, type, def_reg, op2_reg
} else {
| ASM_REG_REG_OP2 cmovb, type, def_reg, op2_reg
| ASM_REG_REG_OP2 cmova, type, def_reg, op2_reg
}
} else {
IR_ASSERT(insn->op == IR_MAX);
if (IR_IS_TYPE_SIGNED(type)) {
| ASM_REG_REG_OP2 cmovg, type, def_reg, op2_reg
} else {
| ASM_REG_REG_OP2 cmova, type, def_reg, op2_reg
} else {
| ASM_REG_REG_OP2 cmovg, type, def_reg, op2_reg
}
}

View File

@ -17,6 +17,6 @@ test:
movl 4(%esp), %eax
movl 8(%esp), %ecx
cmpl %eax, %ecx
cmovll %eax, %ecx
cmovgl %eax, %ecx
movl %ecx, %eax
retl

View File

@ -17,6 +17,6 @@ test:
movb 4(%esp), %al
movb 8(%esp), %cl
cmpb %al, %cl
cmovbw %ax, %cx
cmovaw %ax, %cx
movb %cl, %al
retl

View File

@ -17,5 +17,5 @@ test:
movl 4(%esp), %eax
movl $0x2f, %ecx
cmpl %ecx, %eax
cmovll %ecx, %eax
cmovgl %ecx, %eax
retl

View File

@ -16,5 +16,5 @@ x86_64
test:
movl %esi, %eax
cmpl %edi, %eax
cmovll %edi, %eax
cmovgl %edi, %eax
retq

View File

@ -16,5 +16,5 @@ x86_64
test:
movb %sil, %al
cmpb %dil, %al
cmovbw %di, %ax
cmovaw %di, %ax
retq

View File

@ -17,5 +17,5 @@ test:
movl %edi, %eax
movl $0x2f, %ecx
cmpl %ecx, %eax
cmovll %ecx, %eax
cmovgl %ecx, %eax
retq