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

Fix -0.0 #74

Merged
merged 1 commit into from
May 21, 2021
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
1 change: 1 addition & 0 deletions src/rewriter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ let rec private simplifyExpr env = function
| FunCall(Op "/", [Int (i1, su); Int (i2, _)]) -> Int (i1 / i2, su)
| FunCall(Op "%", [Int (i1, su); Int (i2, _)]) -> Int (i1 % i2, su)

| FunCall(Op "-", [Float (0.0,su)]) -> Float (0.0, su)
| FunCall(Op "-", [Float (f1,su)]) -> Float (-f1, su)
| FunCall(Op "-", [Float (i1,su); Float (i2,_)]) -> Float (i1 - i2, su)
| FunCall(Op "+", [Float (i1,su); Float (i2,_)]) -> Float (i1 + i2, su)
Expand Down
1 change: 1 addition & 0 deletions tests/commands.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
--no-renaming --format c-variables -o tests/unit/blocks.expected tests/unit/blocks.frag
--hlsl --no-renaming --format c-variables -o tests/unit/geometry.hlsl.expected tests/unit/geometry.hlsl
--no-renaming --format c-array -o tests/unit/operators.expected tests/unit/operators.frag
--no-renaming --format c-array -o tests/unit/minus-zero.expected tests/unit/minus-zero.frag

# Partial renaming tests

Expand Down
9 changes: 9 additions & 0 deletions tests/unit/minus-zero.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* File generated with Shader Minifier 1.1.6
* http://www.ctrl-alt-test.fr
*/

// tests/unit/minus-zero.frag
"void main()"
"{"
"float a=0.;"
"}",
4 changes: 4 additions & 0 deletions tests/unit/minus-zero.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
void main()
{
float a = -0.0;
}