-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Add --fast-math
to binaryen passes when linking with -ffast-math
#25513
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
4eaf304
61cddc4
27f9ea7
9c8a095
2b51c42
e986e75
2640bf7
784f573
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15799,3 +15799,30 @@ def has_defined_function(file, func): | |
self.assertIn('main.cpp', out) | ||
self.assertIn('foo.cpp', out) | ||
self.assertIn('/emsdk/emscripten/system/lib/libc/musl/src/string/strcmp.c', out) | ||
|
||
def test_fast_math_debug_output(self): | ||
create_file('test.c', ''' | ||
#include <math.h> | ||
int main() { return (int)(sin(1.0) * 100); } | ||
''') | ||
|
||
err = self.run_process([EMCC, 'test.c', '-v', '-O2', '-ffast-math'], stderr=PIPE).stderr | ||
|
||
self.assertContained('--fast-math', err) | ||
|
||
err_no_fast = self.run_process([EMCC, 'test.c', '-v', '-O2'], stderr=PIPE).stderr | ||
self.assertNotContained('--fast-math', err_no_fast) | ||
|
||
def test_fast_math_size_comparison(self): | ||
create_file('math.c', ''' | ||
#include <math.h> | ||
double f(double x) { return sin(x) * cos(x) + sqrt(x); } | ||
int main() { return (int)f(1.5); } | ||
''') | ||
|
||
|
||
self.run_process([EMCC, 'math.c', '-O2', '-o', 'no_fast.wasm']) | ||
no_fast_size = os.path.getsize('no_fast.wasm') | ||
|
||
self.run_process([EMCC, 'math.c', '-O2', '-ffast-math', '-o', 'with_fast.wasm']) | ||
with_fast_size = os.path.getsize('with_fast.wasm') | ||
|
||
self.assertLessEqual(with_fast_size, no_fast_size) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this need to be |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about calling this test
test_binaryen_fast_math
?