fix(expr): 修复 not 一元运算未取反(i1 条件与 0 比较)
not x 的降级此前写成 (bool(x) == 1),在 i1 上与恒等等价,导致 not r2 不取反(FuncTest Test 7 bool return 失败)。注释本意即 not x = (bool(x) == 0),改为与 i1 常量 0 比较。
This commit is contained in:
1 parent
cc8ea01476
commit
df9a5a9beb
1 file changed
+2
-2
@@ -791,8 +791,8 @@ novirtual class ExprGenOps(ExprGenBase.ExprGenBase):
|
||||
not_cond: llvmlite.Value* = self.coerce_cond_to_bool(pool, builder, mod, operand, trans)
|
||||
if not_cond is None:
|
||||
return None
|
||||
true_val: llvmlite.Value* = llvmlite.const_int(pool, 1, 1)
|
||||
return llvmlite.build_icmp(builder, llvmlite.ICMP_EQ, not_cond, true_val)
|
||||
false_val: llvmlite.Value* = llvmlite.const_int(pool, 0, 1)
|
||||
return llvmlite.build_icmp(builder, llvmlite.ICMP_EQ, not_cond, false_val)
|
||||
elif uo.op == ast.OpKind.Invert:
|
||||
# ~x = x ^ -1
|
||||
operand_bits_inv: int = self.get_llvm_type_bits(operand.Ty)
|
||||
|
||||
Reference in new issue
Block a user