diff --git a/src/cc/backend/codegen_expr.c b/src/cc/backend/codegen_expr.c index 4b58aea32..6f9c0e573 100644 --- a/src/cc/backend/codegen_expr.c +++ b/src/cc/backend/codegen_expr.c @@ -295,10 +295,10 @@ static VReg *gen_ternary(Expr *expr) { BB *nbb = new_bb(); VReg *result = NULL; if (expr->type->kind != TY_VOID) { - if (is_number(expr->type) || ptr_or_array(expr->type)) - result = add_new_reg(expr->type, 0); - else - result = add_new_reg(ptrof(expr->type), 0); + Type *type = expr->type; + if (!is_number(type) && !ptr_or_array(type)) + type = ptrof(type); + result = add_new_reg(type, 0); } gen_cond_jmp(expr->ternary.cond, false, fbb); diff --git a/src/cc/backend/ir.c b/src/cc/backend/ir.c index 87aeefe7d..1d8670538 100644 --- a/src/cc/backend/ir.c +++ b/src/cc/backend/ir.c @@ -105,12 +105,9 @@ VReg *new_ir_bop(enum IrKind kind, VReg *opr1, VReg *opr2, const VRegType *vtype break; case IR_BITAND: if (opr1->fixnum == 0) - return opr1; + return opr1; // 0 break; case IR_BITOR: - if (opr1->fixnum == 0) - return opr2; - break; case IR_BITXOR: if (opr1->fixnum == 0) return opr2; @@ -118,7 +115,7 @@ VReg *new_ir_bop(enum IrKind kind, VReg *opr1, VReg *opr2, const VRegType *vtype case IR_LSHIFT: case IR_RSHIFT: if (opr1->fixnum == 0) - return opr1; + return opr1; // 0 break; default: break; @@ -139,12 +136,9 @@ VReg *new_ir_bop(enum IrKind kind, VReg *opr1, VReg *opr2, const VRegType *vtype break; case IR_BITAND: if (opr2->fixnum == 0) - return opr2; + return opr2; // 0 break; case IR_BITOR: - if (opr2->fixnum == 0) - return opr1; - break; case IR_BITXOR: if (opr2->fixnum == 0) return opr1; diff --git a/src/wcc/gen_wasm.c b/src/wcc/gen_wasm.c index efe0de61f..05cd6406c 100644 --- a/src/wcc/gen_wasm.c +++ b/src/wcc/gen_wasm.c @@ -97,9 +97,7 @@ static int continue_depth; unsigned char to_wtype(const Type *type) { switch (type->kind) { case TY_FIXNUM: return type_size(type) <= I32_SIZE ? WT_I32 : WT_I64; -#ifndef __NO_FLONUM case TY_FLONUM: return type->flonum.kind == FL_FLOAT ? WT_F32 : WT_F64; -#endif case TY_PTR: case TY_ARRAY: // Pointer and array is handled as an index of linear memroy.