Skip to content

Commit

Permalink
Enable powif* intrinsics
Browse files Browse the repository at this point in the history
These are supported by CBMC with
diffblue/cbmc#8192 merged.

Resolves: model-checking#2763
  • Loading branch information
tautschnig committed Feb 7, 2024
1 parent a82bad4 commit ea28adf
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
4 changes: 2 additions & 2 deletions docs/src/rust-feature-support/intrinsics.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,8 @@ nontemporal_store | No | |
offset | Partial | Doesn't check [all UB conditions](https://doc.rust-lang.org/std/primitive.pointer.html#safety-2) |
powf32 | No | |
powf64 | No | |
powif32 | No | |
powif64 | No | |
powif32 | Partial | Results are overapproximated |
powif64 | Partial | Results are overapproximated |
pref_align_of | Yes | |
prefetch_read_data | No | |
prefetch_read_instruction | No | |
Expand Down
4 changes: 2 additions & 2 deletions kani-compiler/src/codegen_cprover_gotoc/codegen/intrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -476,8 +476,8 @@ impl<'tcx> GotocCtx<'tcx> {
),
"powf32" => unstable_codegen!(codegen_simple_intrinsic!(Powf)),
"powf64" => unstable_codegen!(codegen_simple_intrinsic!(Pow)),
"powif32" => unstable_codegen!(codegen_simple_intrinsic!(Powif)),
"powif64" => unstable_codegen!(codegen_simple_intrinsic!(Powi)),
"powif32" => codegen_simple_intrinsic!(Powif),
"powif64" => codegen_simple_intrinsic!(Powi),
"pref_align_of" => codegen_intrinsic_const!(),
"ptr_guaranteed_cmp" => self.codegen_ptr_guaranteed_cmp(fargs, place),
"ptr_offset_from" => self.codegen_ptr_offset_from(fargs, place, loc),
Expand Down
18 changes: 18 additions & 0 deletions tests/kani/Intrinsics/Math/Arith/powi.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright Kani Contributors
// SPDX-License-Identifier: Apache-2.0 OR MIT

#[kani::proof]
fn verify_powi32() {
let x: f32 = kani::any();
kani::assume(x.is_normal());
let x2 = x.powi(2);
assert!(x2 >= 0.0);
}

#[kani::proof]
fn verify_powi64() {
let x: f64 = kani::any();
kani::assume(x.is_normal());
let x2 = x.powi(2);
assert!(x2 >= 0.0);
}

0 comments on commit ea28adf

Please sign in to comment.