* Rewrites 'e' in-place to remove ("join") duplicate and other redundant * operands. * * Example simplifications: * * A || B || A -> A || B * A && B && A=y -> A=y && B * * Returns the deduplicated expression. */
| 662 | * Returns the deduplicated expression. |
| 663 | */ |
| 664 | struct expr *expr_eliminate_dups(struct expr *e) |
| 665 | { |
| 666 | int oldcount; |
| 667 | if (!e) |
| 668 | return e; |
| 669 | |
| 670 | oldcount = trans_count; |
| 671 | while (1) { |
| 672 | trans_count = 0; |
| 673 | switch (e->type) { |
| 674 | case E_OR: case E_AND: |
| 675 | expr_eliminate_dups1(e->type, &e, &e); |
| 676 | default: |
| 677 | ; |
| 678 | } |
| 679 | if (!trans_count) |
| 680 | /* No simplifications done in this pass. We're done */ |
| 681 | break; |
| 682 | e = expr_eliminate_yn(e); |
| 683 | } |
| 684 | trans_count = oldcount; |
| 685 | return e; |
| 686 | } |
| 687 | |
| 688 | /* |
| 689 | * Performs various simplifications involving logical operators and |
no test coverage detected