Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.

Additional simplifications for arithmetic expressions#278

Merged
bettinaheim merged 11 commits intomasterfrom
msoeken/expression-evaluation
Jan 22, 2020
Merged

Additional simplifications for arithmetic expressions#278
bettinaheim merged 11 commits intomasterfrom
msoeken/expression-evaluation

Conversation

@msoeken
Copy link
Member

@msoeken msoeken commented Jan 4, 2020

This PR adds further simplifications involving constants in arithmetic expressions, e.g., x + 0 is transformed into x; and similarly (x - 0, x * 1, x / 1, ...). It also tries to simplify expressions such that x - x becomes 0, 0 - x becomes -x, and x / x becomes 1. Works for all numeric data types.

@msoeken msoeken requested a review from bettinaheim January 4, 2020 08:45
@thomashaener
Copy link

Thanks for adding this @msoeken!
I'd suggest not to perform the rewrite x/x -> 1 though, since the resulting program would not behave as expected, e.g., for x=0 and other special cases.

@msoeken
Copy link
Member Author

msoeken commented Jan 8, 2020

Thanks for adding this @msoeken!
I'd suggest not to perform the rewrite x/x -> 1 though, since the resulting program would not behave as expected, e.g., for x=0 and other special cases.

Thanks, good catch. Removed this case in the most recent commit.

@bettinaheim bettinaheim merged commit 9a3417d into master Jan 22, 2020
@bettinaheim bettinaheim deleted the msoeken/expression-evaluation branch January 22, 2020 17:40
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants