mirror of
https://github.com/danog/ir.git
synced 2024-12-02 09:38:29 +01:00
Fixed GH Issue #34 (Simple if-else IR program compile failure)
This commit is contained in:
parent
4e01e7251e
commit
b5bb5f869a
11
ir_x86.dasc
11
ir_x86.dasc
@ -604,10 +604,8 @@ op2_const:
|
||||
flags = IR_USE_MUST_BE_IN_REG | IR_OP1_MUST_BE_IN_REG | IR_OP2_SHOULD_BE_IN_REG;
|
||||
if (IR_IS_CONST_REF(insn->op1)) {
|
||||
const ir_insn *val_insn = &ctx->ir_base[insn->op1];
|
||||
if (ir_type_size[val_insn->type] == 8 && !IR_IS_32BIT(val_insn->type, val_insn->val)) {
|
||||
constraints->tmp_regs[0] = IR_TMP_REG(1, val_insn->type, IR_LOAD_SUB_REF, IR_DEF_SUB_REF);
|
||||
n = 1;
|
||||
}
|
||||
constraints->tmp_regs[0] = IR_TMP_REG(1, val_insn->type, IR_LOAD_SUB_REF, IR_DEF_SUB_REF);
|
||||
n = 1;
|
||||
} else if (ir_rule(ctx, insn->op1) & IR_FUSED) {
|
||||
flags = IR_USE_MUST_BE_IN_REG | IR_OP2_MUST_BE_IN_REG;
|
||||
}
|
||||
@ -619,11 +617,6 @@ op2_const:
|
||||
n++;
|
||||
}
|
||||
}
|
||||
if (n == 0 && IR_IS_CONST_REF(insn->op1) && IR_IS_CONST_REF(insn->op2)) {
|
||||
insn = &ctx->ir_base[insn->op1];
|
||||
constraints->tmp_regs[n] = IR_TMP_REG(2, insn->type, IR_LOAD_SUB_REF, IR_DEF_SUB_REF);
|
||||
n++;
|
||||
}
|
||||
break;
|
||||
case IR_CMP_FP:
|
||||
insn = &ctx->ir_base[ref];
|
||||
|
32
tests/bugs/gh-00034.irt
Normal file
32
tests/bugs/gh-00034.irt
Normal file
@ -0,0 +1,32 @@
|
||||
--TEST--
|
||||
GH-34: Simple if-else IR program compile failure
|
||||
--TARGET--
|
||||
x86_64
|
||||
--ARGS--
|
||||
-O0 -S
|
||||
--CODE--
|
||||
{
|
||||
uintptr_t c_1 = 0;
|
||||
bool c_2 = 0;
|
||||
bool c_3 = 1;
|
||||
int32_t c_4 = 1;
|
||||
int32_t c_5 = 4;
|
||||
l_1 = START(l_9);
|
||||
int32_t p = PARAM(l_1, "p", 1);
|
||||
bool d_2 = LT(c_4, c_5);
|
||||
l_3 = IF(l_1, d_2);
|
||||
l_4 = IF_TRUE(l_3);
|
||||
l_5 = END(l_4);
|
||||
l_6 = IF_FALSE(l_3);
|
||||
l_7 = END(l_6);
|
||||
l_8 = MERGE(l_5, l_7);
|
||||
l_9 = RETURN(l_8, c_5);
|
||||
}
|
||||
--EXPECT--
|
||||
test:
|
||||
movl $1, %eax
|
||||
cmpl $4, %eax
|
||||
jge .L1
|
||||
.L1:
|
||||
movl $4, %eax
|
||||
retq
|
Loading…
Reference in New Issue
Block a user