From ff44f05726c5a4968f8821a1b72ee04e3e193c1c Mon Sep 17 00:00:00 2001 From: Edward Chen Date: Wed, 10 Aug 2022 03:21:52 -0400 Subject: [PATCH 1/3] added gcd and psi test cases --- examples/C/mpc/benchmarks/db/db_join.c | 10 ++-- examples/C/mpc/benchmarks/gcd/gcd.c | 15 ++++++ examples/C/mpc/benchmarks/psi/psi.c | 29 ++++++++++ examples/C/mpc/playground.c | 74 +++----------------------- examples/circ.rs | 2 +- scripts/aby_tests/c_test_aby.py | 4 +- scripts/aby_tests/test_inputs/gcd.txt | 3 ++ scripts/aby_tests/test_inputs/psi.txt | 3 ++ scripts/aby_tests/test_suite.py | 17 ++++++ scripts/build_mpc_c_test.zsh | 5 ++ src/ir/opt/mem/lin.rs | 3 +- src/ir/opt/mem/mod.rs | 7 ++- src/ir/term/text/mod.rs | 5 +- 13 files changed, 97 insertions(+), 80 deletions(-) create mode 100644 examples/C/mpc/benchmarks/gcd/gcd.c create mode 100644 examples/C/mpc/benchmarks/psi/psi.c create mode 100644 scripts/aby_tests/test_inputs/gcd.txt create mode 100644 scripts/aby_tests/test_inputs/psi.txt diff --git a/examples/C/mpc/benchmarks/db/db_join.c b/examples/C/mpc/benchmarks/db/db_join.c index e7076b7e..d0fd64ee 100644 --- a/examples/C/mpc/benchmarks/db/db_join.c +++ b/examples/C/mpc/benchmarks/db/db_join.c @@ -11,13 +11,13 @@ #include "db.h" int cross_join(DT *OUTPUT_db, DT *a, DT *b) { - int id_a = 0; - int id_b = 0; + // int id_a = 0; + // int id_b = 0; int id_out = 0; - for(int i = 0; i < LEN_A*LEN_B*ATT+1; i++) { - OUTPUT_db[i] = 0;//-1; - } + // for(int i = 0; i < LEN_A*LEN_B*ATT+1; i++) { + // OUTPUT_db[i] = 0;//-1; + // } for(int i = 0; i < LEN_A; i++) { for(int j = 0; j < LEN_B; j++) { diff --git a/examples/C/mpc/benchmarks/gcd/gcd.c b/examples/C/mpc/benchmarks/gcd/gcd.c new file mode 100644 index 00000000..1beaaa58 --- /dev/null +++ b/examples/C/mpc/benchmarks/gcd/gcd.c @@ -0,0 +1,15 @@ +int LEN = 32; +int main( __attribute__((private(0))) int a, __attribute__((private(1))) int b) { + int gcd = 0; + for (int i = 0; i < LEN; i++) { + if (b != 0){ + gcd = a % b; + int temp = b; + b = gcd; + a = temp; + } else{ + gcd = a; + } + } + return gcd; +} \ No newline at end of file diff --git a/examples/C/mpc/benchmarks/psi/psi.c b/examples/C/mpc/benchmarks/psi/psi.c new file mode 100644 index 00000000..460ea49a --- /dev/null +++ b/examples/C/mpc/benchmarks/psi/psi.c @@ -0,0 +1,29 @@ +#define SIZE_1 32 +#define SIZE_2 1024 + +int contains(int pset[SIZE_2], int target) { + int result = 0; + for(int i = 0; i < SIZE_2; i++){ + int old_result = result; + if(pset[i] == target){ + result = 1; + } else{ + result = old_result; + } + } + return result; +} + + +int main(__attribute__((private(0))) int pset1[SIZE_1], __attribute__((private(1))) int pset2[SIZE_2]) { + int intersection[SIZE_1]; + for(int i = 0; i < SIZE_1; i++) { + int result = contains(pset2, pset1[i]); + intersection[i] = result; + } + int sum = 0; + for (int i = 0; i < SIZE_1; i++){ + sum += intersection[i]; + } + return sum; +} \ No newline at end of file diff --git a/examples/C/mpc/playground.c b/examples/C/mpc/playground.c index 61b04f8c..9582786c 100644 --- a/examples/C/mpc/playground.c +++ b/examples/C/mpc/playground.c @@ -1,69 +1,7 @@ -#define LEN 32 -#define NUM_REVIEWERS 1 -#define NUM_RATINGS 1 -#define INTERVALS 2 -#define NUM_BUCKETS (INTERVALS * 5) - 1 -#define TOTAL_REV (NUM_REVIEWERS * NUM_RATINGS) - - -int main(__attribute__((private(0))) int reviews[TOTAL_REV], __attribute__((private(1))) int offset) -{ - int result[NUM_BUCKETS]; - for(int i = 0; i < NUM_BUCKETS; i ++){ - result[i] = 0; +int main(__attribute__((private(0))) int a, __attribute__((private(1))) int b) { + int c[1]; + if (a < b) { + c[0] = 1; } - for (int i = 0; i < NUM_REVIEWERS; i++) { - int sum = 0; - for (int j = 0; j < NUM_RATINGS; j++) { - sum = sum + reviews[i*NUM_RATINGS + j]; - } - int bucket = sum; - for (int j = 0; j < NUM_BUCKETS; j++) { - int temp; - if (j == bucket) { - temp = result[j] + 1; - } - else { - temp = result[j]; - } - result[j] = temp; - } - } - int sum_all = offset; - for(int i = 0; i < NUM_BUCKETS; i++){ - sum_all += result[i]; - } - return sum_all; -} - - -// int main(__attribute__((private(0))) int a, __attribute__((private(1))) int b) { -// int c = a * b; -// return c + a; -// } - - -// int f(int a) { -// return a + 1; -// } - -// int main( __attribute__((private(0))) int a, __attribute__((private(1))) int b) -// { -// // base input -// int c = f(a); -// int d = f(b); - -// // add input -// int e = a + c; -// int g = b + d; -// int h = f(e); -// int i = f(g); - -// // multiply input -// int j = a * h; -// int k = b * i; -// int l = f(j); -// int m = f(k); - -// return l + m; -// } \ No newline at end of file + return c[0]; +} \ No newline at end of file diff --git a/examples/circ.rs b/examples/circ.rs index 5aea8faf..8a8be75f 100644 --- a/examples/circ.rs +++ b/examples/circ.rs @@ -295,7 +295,7 @@ fn main() { // for (name, c) in &cs.computations { // println!("name: {}", name); // for t in c.terms_postorder() { - // println!("t: {}", t.op); + // println!("t: {}", t); // } // } diff --git a/scripts/aby_tests/c_test_aby.py b/scripts/aby_tests/c_test_aby.py index e2c6c6fb..ac06dc51 100755 --- a/scripts/aby_tests/c_test_aby.py +++ b/scripts/aby_tests/c_test_aby.py @@ -29,7 +29,9 @@ if __name__ == "__main__": db_tests + \ mnist_tests + \ cryptonets_tests + \ - histogram_tests + histogram_tests + \ + gcd_tests + \ + psi_tests # TODO: add support unsigned + int promotion # unsigned_arithmetic_tests + \ diff --git a/scripts/aby_tests/test_inputs/gcd.txt b/scripts/aby_tests/test_inputs/gcd.txt new file mode 100644 index 00000000..c8efa34e --- /dev/null +++ b/scripts/aby_tests/test_inputs/gcd.txt @@ -0,0 +1,3 @@ +a 250 +b 150 +res 50 \ No newline at end of file diff --git a/scripts/aby_tests/test_inputs/psi.txt b/scripts/aby_tests/test_inputs/psi.txt new file mode 100644 index 00000000..b285c936 --- /dev/null +++ b/scripts/aby_tests/test_inputs/psi.txt @@ -0,0 +1,3 @@ +pset1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 +pset2 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 +res 32 \ No newline at end of file diff --git a/scripts/aby_tests/test_suite.py b/scripts/aby_tests/test_suite.py index c3c88da4..8a543ca6 100644 --- a/scripts/aby_tests/test_suite.py +++ b/scripts/aby_tests/test_suite.py @@ -648,6 +648,23 @@ histogram_tests = [ ] ] +gcd_tests = [ + [ + "gcd", + "gcd", + "./scripts/aby_tests/test_inputs/gcd.txt", + ] +] + +psi_tests = [ + [ + "psi", + "psi", + "./scripts/aby_tests/test_inputs/psi.txt", + ] +] + + # ilp_benchmark_tests = [ # [ # "ilp bench - array sum 1", diff --git a/scripts/build_mpc_c_test.zsh b/scripts/build_mpc_c_test.zsh index 4a3559d6..bb272716 100755 --- a/scripts/build_mpc_c_test.zsh +++ b/scripts/build_mpc_c_test.zsh @@ -36,6 +36,8 @@ function mpc_test_bool { RUST_BACKTRACE=1 measure_time $BIN --parties $parties $cpath mpc --cost-model "hycc" --selection-scheme "b" } +# mpc_test 2 ./examples/C/mpc/playground.c + # build mpc arithmetic tests mpc_test 2 ./examples/C/mpc/unit_tests/arithmetic_tests/2pc_add.c mpc_test 2 ./examples/C/mpc/unit_tests/arithmetic_tests/2pc_sub.c @@ -131,6 +133,9 @@ mpc_test_2 2 ./examples/C/mpc/benchmarks/cryptonets/cryptonets_16.c # build OPA benchmarks mpc_test_2 2 ./examples/C/mpc/benchmarks/histogram/histogram.c +mpc_test_2 2 ./examples/C/mpc/benchmarks/gcd/gcd.c +mpc_test_2 2 ./examples/C/mpc/benchmarks/psi/psi.c + # # # mpc_test 2 ./examples/C/mpc/benchmarks/kmeans/2pc_kmeans.c # # # mpc_test 2 ./examples/C/mpc/benchmarks/kmeans/2pc_kmeans_og.c diff --git a/src/ir/opt/mem/lin.rs b/src/ir/opt/mem/lin.rs index a31da629..9d9991fc 100644 --- a/src/ir/opt/mem/lin.rs +++ b/src/ir/opt/mem/lin.rs @@ -133,7 +133,8 @@ mod test { #[test] fn select_ite_stores() { - let before = text::parse_computation(b" + let before = text::parse_computation( + b" (computation (metadata () () ()) (let ((z (#a (bv 4) #x0 6 ()))) diff --git a/src/ir/opt/mem/mod.rs b/src/ir/opt/mem/mod.rs index 803bee01..8b96db75 100644 --- a/src/ir/opt/mem/mod.rs +++ b/src/ir/opt/mem/mod.rs @@ -43,7 +43,12 @@ fn array_to_tuple(t: &Term) -> Term { .map(|c| array_to_tuple(&c)) .collect(), ), - Sort::Tuple(..) => term(Op::Tuple, extras::tuple_elements(t).map(|c| array_to_tuple(&c)).collect()), + Sort::Tuple(..) => term( + Op::Tuple, + extras::tuple_elements(t) + .map(|c| array_to_tuple(&c)) + .collect(), + ), _ => t.clone(), } } diff --git a/src/ir/term/text/mod.rs b/src/ir/term/text/mod.rs index 42fc7ff1..86b29975 100644 --- a/src/ir/term/text/mod.rs +++ b/src/ir/term/text/mod.rs @@ -1,9 +1,9 @@ //! Defines a textual serialization format for [Term]s. //! //! Includes a parser ([parse_term]) and serializer ([serialize_term]) for [Term]s. -//! +//! //! Includes a parser ([parse_value_map]) and serializer ([serialize_value_map]) for value maps. -//! +//! //! Includes a parser ([parse_computation]) and serializer ([serialize_computation]) for [Computation]s. //! //! @@ -752,7 +752,6 @@ pub fn serialize_functions(fns: &Functions) -> String { out } - #[cfg(test)] mod test { use super::*; From c27f471999bd1962b3ca0435e0ce6b032d9ec864 Mon Sep 17 00:00:00 2001 From: Edward Chen Date: Wed, 10 Aug 2022 04:07:24 -0400 Subject: [PATCH 2/3] added ITE optimization --- examples/C/mpc/playground.c | 6 ++--- examples/circ.rs | 1 + scripts/build_mpc_c_test.zsh | 2 +- src/ir/opt/ite.rs | 48 ++++++++++++++++++++++++++++++++++++ src/ir/opt/mod.rs | 6 +++++ 5 files changed, 59 insertions(+), 4 deletions(-) create mode 100644 src/ir/opt/ite.rs diff --git a/examples/C/mpc/playground.c b/examples/C/mpc/playground.c index 9582786c..e75de495 100644 --- a/examples/C/mpc/playground.c +++ b/examples/C/mpc/playground.c @@ -1,7 +1,7 @@ int main(__attribute__((private(0))) int a, __attribute__((private(1))) int b) { - int c[1]; if (a < b) { - c[0] = 1; + return 1; + } else { + return 2; } - return c[0]; } \ No newline at end of file diff --git a/examples/circ.rs b/examples/circ.rs index 8a8be75f..23f6523b 100644 --- a/examples/circ.rs +++ b/examples/circ.rs @@ -254,6 +254,7 @@ fn main() { // The linear scan pass produces more tuples, that must be eliminated Opt::Tuple, Opt::ConstantFold(Box::new(ignore.clone())), + Opt::Ite, // Inline Function Calls // Opt::Link, // Opt::Tuple, diff --git a/scripts/build_mpc_c_test.zsh b/scripts/build_mpc_c_test.zsh index bb272716..74c13c09 100755 --- a/scripts/build_mpc_c_test.zsh +++ b/scripts/build_mpc_c_test.zsh @@ -36,7 +36,7 @@ function mpc_test_bool { RUST_BACKTRACE=1 measure_time $BIN --parties $parties $cpath mpc --cost-model "hycc" --selection-scheme "b" } -# mpc_test 2 ./examples/C/mpc/playground.c +# mpc_test 2 ./examples/C/mpc/playground.c # build mpc arithmetic tests mpc_test 2 ./examples/C/mpc/unit_tests/arithmetic_tests/2pc_add.c diff --git a/src/ir/opt/ite.rs b/src/ir/opt/ite.rs new file mode 100644 index 00000000..05bc6d82 --- /dev/null +++ b/src/ir/opt/ite.rs @@ -0,0 +1,48 @@ +//! Rewrite ITE terms + +use crate::ir::opt::cfold::fold; +use crate::ir::opt::visit::RewritePass; +use crate::ir::term::*; + +/// ITE cache. +#[derive(Default)] +struct IteRewriter; + +impl RewritePass for IteRewriter { + fn visit Vec>( + &mut self, + _computation: &mut Computation, + orig: &Term, + rewritten_children: F, + ) -> Option { + let cs = rewritten_children(); + match &orig.op { + Op::Ite => { + let sel = cs[0].clone(); + let t = cs[1].clone(); + let f = cs[2].clone(); + match f.op { + Op::Ite => { + let child_sel = f.cs[0].clone(); + let child_t = f.cs[1].clone(); + if sel + == term![AND; term![Op::Not; child_sel.clone()], term![Op::Not; child_sel.clone()]] + { + Some(term![Op::Ite; child_sel, child_t, t]) + } else { + None + } + } + _ => None, + } + } + _ => None, + } + } +} + +/// Binarize (expand) n-ary terms. +pub fn rewrite_ites(c: &mut Computation) { + let mut pass = IteRewriter; + pass.traverse(c); +} diff --git a/src/ir/opt/mod.rs b/src/ir/opt/mod.rs index 23b5560b..455a43e1 100644 --- a/src/ir/opt/mod.rs +++ b/src/ir/opt/mod.rs @@ -3,6 +3,7 @@ pub mod binarize; pub mod cfold; pub mod flat; pub mod inline; +pub mod ite; pub mod link; pub mod mem; pub mod scalarize_vars; @@ -38,6 +39,8 @@ pub enum Opt { FlattenAssertions, /// Find outputs like `(= variable term)`, and substitute out `variable` Inline, + /// Ite peephole optimizations + Ite, /// Link function calls Link, /// Eliminate tuples @@ -108,6 +111,9 @@ pub fn opt>(mut fs: Functions, optimizations: I) -> Opt::Binarize => { binarize::binarize(comp); } + Opt::Ite => { + ite::rewrite_ites(comp); + } Opt::Inline => { let public_inputs = comp .metadata From 1ce7832f3c0e721df733568b6056f77c7f9272bc Mon Sep 17 00:00:00 2001 From: Edward Chen Date: Wed, 10 Aug 2022 14:49:42 -0400 Subject: [PATCH 3/3] updated ite opt --- examples/C/mpc/playground.c | 17 +++++++++++++++-- examples/circ.rs | 1 - src/ir/opt/cfold.rs | 35 +++++++++++++++++++++++++++++++++-- src/ir/opt/ite.rs | 5 +---- 4 files changed, 49 insertions(+), 9 deletions(-) diff --git a/examples/C/mpc/playground.c b/examples/C/mpc/playground.c index e75de495..59ddcc9d 100644 --- a/examples/C/mpc/playground.c +++ b/examples/C/mpc/playground.c @@ -1,7 +1,20 @@ int main(__attribute__((private(0))) int a, __attribute__((private(1))) int b) { + // if (a < b) { + // return 1; + // } else { + // return 2; + // } if (a < b) { - return 1; + if (a < b) { + return 1; + } else { + return 2; + } } else { - return 2; + if (a < b) { + return 1; + } else { + return 2; + } } } \ No newline at end of file diff --git a/examples/circ.rs b/examples/circ.rs index 23f6523b..be9dab7c 100644 --- a/examples/circ.rs +++ b/examples/circ.rs @@ -290,7 +290,6 @@ fn main() { }; #[cfg(feature = "bench")] println!("LOG: Optimizations: {:#?}", now.elapsed()); - println!("Done with IR optimization"); // for (name, c) in &cs.computations { diff --git a/src/ir/opt/cfold.rs b/src/ir/opt/cfold.rs index 84b7efd4..151e79b3 100644 --- a/src/ir/opt/cfold.rs +++ b/src/ir/opt/cfold.rs @@ -5,7 +5,7 @@ use crate::ir::term::*; use circ_fields::FieldV; use lazy_static::lazy_static; use rug::Integer; -use std::collections::HashMap; +use std::collections::{HashMap, HashSet}; use std::ops::DerefMut; use std::sync::RwLock; @@ -110,7 +110,38 @@ pub fn fold_cache(node: &Term, cache: &mut TermCache, ignore: &[Op]) -> T Some(bv) => cbool(bv.bit(*i)), _ => None, }, - Op::BoolNaryOp(o) => Some(o.clone().flatten(t.cs.iter().map(|c| c_get(c)))), + Op::BoolNaryOp(o) => match o { + BoolNaryOp::Xor | BoolNaryOp::Or => { + Some(o.clone().flatten(t.cs.iter().map(|c| c_get(c)))) + } + BoolNaryOp::And => { + let children = o.clone().flatten(t.cs.iter().map(|c| c_get(c))); + let mut dedup_children: HashSet = HashSet::new(); + for t in children.cs.iter() { + dedup_children.insert(t.clone()); + } + let mut flag = true; + for a in dedup_children.iter() { + for b in dedup_children.iter() { + if term![Op::Not; a.clone()] == *b { + flag = false; + } + } + } + let dedup_children = dedup_children.into_iter().collect::>().clone(); + if !flag { + Some(bool_lit(false)) + } else if AND == children.op { + if dedup_children.len() == 1 { + Some(dedup_children[0].clone()) + } else { + Some(term(AND, dedup_children.clone())) + } + } else { + Some(children) + } + } + }, Op::Eq => { let c0 = get(0); let c1 = get(1); diff --git a/src/ir/opt/ite.rs b/src/ir/opt/ite.rs index 05bc6d82..9c4a698a 100644 --- a/src/ir/opt/ite.rs +++ b/src/ir/opt/ite.rs @@ -1,6 +1,5 @@ //! Rewrite ITE terms -use crate::ir::opt::cfold::fold; use crate::ir::opt::visit::RewritePass; use crate::ir::term::*; @@ -25,9 +24,7 @@ impl RewritePass for IteRewriter { Op::Ite => { let child_sel = f.cs[0].clone(); let child_t = f.cs[1].clone(); - if sel - == term![AND; term![Op::Not; child_sel.clone()], term![Op::Not; child_sel.clone()]] - { + if sel == term![Op::Not; child_sel.clone()] { Some(term![Op::Ite; child_sel, child_t, t]) } else { None