Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

write_aig: Normalize symmetry in multiplication #1833

Merged
merged 2 commits into from
Mar 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion deps/aig
Submodule aig updated 2 files
+1 −1 aig.cabal
+30 −1 src/Data/AIG/Operations.hs
17 changes: 17 additions & 0 deletions intTests/test1788/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
CC = clang
CFLAGS = -g -frecord-command-line -O0

all: test.bc test.exe

test.bc: test.c
$(CC) $(CFLAGS) -c -emit-llvm $< -o $@

test.o: test.c
$(CC) $(CFLAGS) -c $< -o $@

test.exe: test.o
$(CC) $(CFLAGS) $< -o $@

.PHONY: clean
clean:
rm -f test.bc test.exe
Binary file added intTests/test1788/test.bc
Binary file not shown.
5 changes: 5 additions & 0 deletions intTests/test1788/test.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include <stdint.h>

uint32_t mult(uint32_t x) {
return x * 0x85EBCA77U;
}
13 changes: 13 additions & 0 deletions intTests/test1788/test.saw
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// This test case ensures that ABC can prove that a C implementation of the
// `mult` function is equivalent to a direct Cryptol implementation of the
// same function.

let
{{
cryptol_mult : [32] -> [32]
cryptol_mult x = x * 0x85EBCA77
}};

m <- llvm_load_module "test.bc";
llvm_mult <- llvm_extract m "mult";
prove abc {{ \x -> llvm_mult x == cryptol_mult x }};
3 changes: 3 additions & 0 deletions intTests/test1788/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
set -e

$SAW test.saw
2 changes: 2 additions & 0 deletions intTests/test1828/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
left.aig
right.aig
2 changes: 2 additions & 0 deletions intTests/test1828/test.saw
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
write_aig "left.aig" {{ \x -> x * 0x12345678 }};
write_aig "right.aig" {{ \x -> 0x12345678 * x }};
9 changes: 9 additions & 0 deletions intTests/test1828/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
set -e

# This test case uses `write_aiger` to produce AIG files for two nearly
# identical functions, where the only difference is the order of arguments (one
# symbolic and one concrete) in a bitvector multiplication. If the `aig` library
# does its job correctly, these should produce identical AIG files, so check
# this using `diff`.
$SAW test.saw
diff -ru left.aig right.aig