Skip to content

Commit def3a09

Browse files
committed
Previous upgrade
1 parent e906cde commit def3a09

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

kani-compiler/src/codegen_cprover_gotoc/codegen/rvalue.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ impl<'tcx> GotocCtx<'tcx> {
376376
BinOp::BitXor | BinOp::BitAnd | BinOp::BitOr => {
377377
self.codegen_unchecked_scalar_binop(op, e1, e2)
378378
}
379-
BinOp::Eq | BinOp::Lt | BinOp::Le | BinOp::Ne | BinOp::Ge | BinOp::Gt => {
379+
BinOp::Eq | BinOp::Lt | BinOp::Le | BinOp::Ne | BinOp::Ge | BinOp::Gt | BinOp::Cmp => {
380380
let op_ty = self.operand_ty_stable(e1);
381381
if self.is_fat_pointer_stable(op_ty) {
382382
self.codegen_comparison_fat_ptr(op, e1, e2, loc)
@@ -1465,6 +1465,14 @@ fn comparison_expr(op: &BinOp, left: Expr, right: Expr, is_float: bool) -> Expr
14651465
}
14661466
BinOp::Ge => left.ge(right),
14671467
BinOp::Gt => left.gt(right),
1468+
BinOp::Cmp => {
1469+
// Implement https://doc.rust-lang.org/core/cmp/trait.Ord.html as done in cranelift,
1470+
// i.e., (left > right) - (left < right)
1471+
left.clone()
1472+
.gt(right.clone())
1473+
.cast_to(Type::c_int())
1474+
.sub(left.lt(right).cast_to(Type::c_int()))
1475+
}
14681476
_ => unreachable!(),
14691477
}
14701478
}

rust-toolchain.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
# SPDX-License-Identifier: Apache-2.0 OR MIT
33

44
[toolchain]
5-
channel = "nightly-2024-04-02"
5+
channel = "nightly-2024-04-03"
66
components = ["llvm-tools-preview", "rustc-dev", "rust-src", "rustfmt"]

0 commit comments

Comments
 (0)