Commit 5a5f25f
committed
Bitcast constant folding across int/float types
Add cross-type bitcast constant folding that reinterprets bit patterns:
- Integer → float: Bitcast(IntToExpr(Const N)) → FloatToExpr(FConst f)
with 32-bit width guard via ResultWidth, and unconditional for Const64
- Float → integer: Bitcast(FloatToExpr(FConst f)) → IntToExpr(Const n)
Four new primitives handle the bit reinterpretation:
- bitcast-i32-to-f: lower 32 bits as f32, promoted to f64
- bitcast-i64-to-f: all 64 bits as f64
- bitcast-f-to-i32: f64 demoted to f32, bits as i64
- bitcast-f-to-i64: f64 bits as i64
This matches the C++ BitCastScalarOrVector folding rule.1 parent fc81bc3 commit 5a5f25f
2 files changed
Lines changed: 48 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
487 | 487 | | |
488 | 488 | | |
489 | 489 | | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
490 | 510 | | |
491 | 511 | | |
492 | 512 | | |
| |||
908 | 928 | | |
909 | 929 | | |
910 | 930 | | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
911 | 945 | | |
912 | 946 | | |
913 | 947 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
486 | 486 | | |
487 | 487 | | |
488 | 488 | | |
489 | | - | |
490 | | - | |
| 489 | + | |
491 | 490 | | |
492 | 491 | | |
493 | 492 | | |
494 | 493 | | |
495 | 494 | | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
496 | 508 | | |
497 | 509 | | |
498 | 510 | | |
| |||
0 commit comments