Open
Description
CBMC version: 5.61.0
Operating system: Ubuntu 20.04
CBMC manages to solve the following program quickly:
#include <assert.h>
int main() {
int x;
int y;
int o1 = x * y;
int o2 = x * y;
assert(o1 == o2);
return 0;
}
$ /usr/bin/time -p cbmc repeat_no_temp_vars.c
CBMC version 5.61.0 (cbmc-5.61.0) 64-bit x86_64 linux
Parsing repeat_no_temp_vars.c
<snip>
** Results:
repeat_no_temp_vars.c function main
[main.assertion.1] line 8 assertion o1 == o2: SUCCESS
** 0 of 1 failed (1 iterations)
VERIFICATION SUCCESSFUL
real 0.02
user 0.01
sys 0.00
But if I inject temporary variables:
#include <assert.h>
int main() {
int x;
int y;
int t1 = x;
int t2 = y;
int o1 = t1 * t2;
int t3 = x;
int t4 = y;
int o2 = t3 * t4;
assert(o1 == o2);
return 0;
}
it runs for >10 minutes without terminating.
Are there possible optimizations/reductions that would allow discovering that the two expressions are equivalent?
Such an optimization would particularly be helpful for Kani because its codegen flow produces lots of temporary variables (e.g. due to SSA). This makes programs like this one model-checking/kani#1351 difficult to solve even though the Rust program itself does not involve temporary variables.