Commit 400ec54
committed
Add safety guards for division and modulo optimizations
Implement zero-check guards to prevent undefined behavior in:
- x / x = 1 optimization (only when x is provably non-zero)
- x % x = 0 optimization (only when x is provably non-zero)
- x / 1 = x and x % 1 = 0 (always safe)
These guards ensure correctness by only applying optimizations
when operands are compile-time constants with non-zero values,
addressing reviewer concerns about potential division by zero.1 parent a06e3c6 commit 400ec54
1 file changed
+35
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1884 | 1884 | | |
1885 | 1885 | | |
1886 | 1886 | | |
1887 | | - | |
| 1887 | + | |
| 1888 | + | |
| 1889 | + | |
| 1890 | + | |
| 1891 | + | |
| 1892 | + | |
| 1893 | + | |
| 1894 | + | |
| 1895 | + | |
| 1896 | + | |
| 1897 | + | |
| 1898 | + | |
| 1899 | + | |
| 1900 | + | |
| 1901 | + | |
| 1902 | + | |
| 1903 | + | |
| 1904 | + | |
| 1905 | + | |
| 1906 | + | |
| 1907 | + | |
| 1908 | + | |
| 1909 | + | |
| 1910 | + | |
| 1911 | + | |
| 1912 | + | |
| 1913 | + | |
| 1914 | + | |
| 1915 | + | |
| 1916 | + | |
| 1917 | + | |
| 1918 | + | |
| 1919 | + | |
| 1920 | + | |
| 1921 | + | |
1888 | 1922 | | |
1889 | 1923 | | |
1890 | 1924 | | |
| |||
0 commit comments