Skip to content

Commit

Permalink
Merge pull request #1833 from GaloisInc/T1828
Browse files Browse the repository at this point in the history
`write_aig`: Normalize symmetry in multiplication
  • Loading branch information
mergify[bot] authored Mar 9, 2023
2 parents 8eaf10e + 5c83772 commit 81db13e
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 1 deletion.
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

0 comments on commit 81db13e

Please sign in to comment.