Skip to content

Commit d23a20d

Browse files
authored
Enable nontrapping-fp by default (#23007)
Enable nontrapping-fptoint by lowering the browser target requirement. Once all 3 Safari 15 features have been enabled, I will reset the requirement correctly.
1 parent aead0b0 commit d23a20d

29 files changed

+66
-50
lines changed

ChangeLog.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ See docs/process.md for more on how version tagging works.
2020

2121
3.1.75 (in development)
2222
-----------------------
23+
- The Wasm nontrapping-fptoint feature has been enabled by default. clang will
24+
generate nontrapping (saturating) float-to-int conversion instructions for
25+
C typecasts. This should have no effect on programs that do not have
26+
undefined behavior but if the casted floating-point value is outside the range
27+
of the target integer type, the result will be a number of the max or min value
28+
instead of a trap. This also results in a small code size improvement because
29+
of details of the LLVM IR semantics. This feature can be disabled in clang with
30+
the -mno-nontrapping-fptoint flag. (#23007)
2331
- The `WASM_BIGINT` feature has been enabled by default. This has the effect that
2432
Wasm i64 values are passed and returned between Wasm and JS as BigInt values
2533
rather than being split by Binaryen into pairs of Numbers. (#22993)

emcc.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,8 +392,6 @@ def get_clang_flags(user_args):
392392
if not settings.BULK_MEMORY:
393393
flags.append('-mno-bulk-memory')
394394
flags.append('-mno-bulk-memory-opt')
395-
if '-mnontrapping-fptoint' not in user_args and '-mno-nontrapping-fptoint' not in user_args:
396-
flags.append('-mno-nontrapping-fptoint')
397395

398396
if settings.RELOCATABLE and '-fPIC' not in user_args:
399397
flags.append('-fPIC')
@@ -1435,6 +1433,12 @@ def consume_arg_file():
14351433
override=True)
14361434
elif arg == '-mno-sign-ext':
14371435
feature_matrix.disable_feature(feature_matrix.Feature.SIGN_EXT)
1436+
elif arg == '-mnontrappting-fptoint':
1437+
feature_matrix.enable_feature(feature_matrix.Feature.NON_TRAPPING_FPTOINT,
1438+
'-mnontrapping-fptoint',
1439+
override=True)
1440+
elif arg == '-mno-nontrapping-fptoint':
1441+
feature_matrix.disable_feature(feature_matrix.Feature.NON_TRAPPING_FPTOINT)
14381442
elif arg == '-fexceptions':
14391443
# TODO Currently -fexceptions only means Emscripten EH. Switch to wasm
14401444
# exception handling by default when -fexceptions is given when wasm

test/code_size/hello_webgl2_wasm.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"a.html.gz": 328,
44
"a.js": 4538,
55
"a.js.gz": 2320,
6-
"a.wasm": 10402,
7-
"a.wasm.gz": 6703,
8-
"total": 15394,
9-
"total_gz": 9351
6+
"a.wasm": 10206,
7+
"a.wasm.gz": 6663,
8+
"total": 15198,
9+
"total_gz": 9311
1010
}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"a.html": 346,
33
"a.html.gz": 262,
4-
"a.js": 22206,
5-
"a.js.gz": 11589,
6-
"total": 22552,
7-
"total_gz": 11851
4+
"a.js": 22202,
5+
"a.js.gz": 11604,
6+
"total": 22548,
7+
"total_gz": 11866
88
}

test/code_size/hello_webgl_wasm.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"a.html.gz": 328,
44
"a.js": 4076,
55
"a.js.gz": 2163,
6-
"a.wasm": 10402,
7-
"a.wasm.gz": 6703,
8-
"total": 14932,
9-
"total_gz": 9194
6+
"a.wasm": 10206,
7+
"a.wasm.gz": 6663,
8+
"total": 14736,
9+
"total_gz": 9154
1010
}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"a.html": 346,
33
"a.html.gz": 262,
4-
"a.js": 21732,
5-
"a.js.gz": 11419,
6-
"total": 22078,
7-
"total_gz": 11681
4+
"a.js": 21728,
5+
"a.js.gz": 11435,
6+
"total": 22074,
7+
"total_gz": 11697
88
}

test/code_size/math_wasm.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"a.html.gz": 380,
44
"a.js": 110,
55
"a.js.gz": 125,
6-
"a.wasm": 2719,
7-
"a.wasm.gz": 1675,
8-
"total": 3381,
9-
"total_gz": 2180
6+
"a.wasm": 2695,
7+
"a.wasm.gz": 1664,
8+
"total": 3357,
9+
"total_gz": 2169
1010
}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"a.html": 12597,
3-
"a.html.gz": 6882,
4-
"total": 12597,
5-
"total_gz": 6882
2+
"a.html": 12517,
3+
"a.html.gz": 6871,
4+
"total": 12517,
5+
"total_gz": 6871
66
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"a.html": 17195,
3-
"a.html.gz": 7478,
3+
"a.html.gz": 7480,
44
"total": 17195,
5-
"total_gz": 7478
5+
"total_gz": 7480
66
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
128974
1+
128914

0 commit comments

Comments
 (0)