Commit db78fae
Support whole-number float exponents in ReplacePowWithMulPass (#18851)
Summary:
Pull Request resolved: #18851
Extend `ReplacePowWithMulPass` to accept float exponents that are whole numbers
(e.g., 2.0, 3.0, 4.0) in addition to integer exponents. Previously the pass only
matched `int` typed exponents, causing it to miss valid optimization opportunities
when the exponent was a float with no fractional part.
Changes:
- Broaden the type check from `isinstance(_, int)` to `isinstance(_, (int, float))`
- Add a guard to reject non-whole-number floats (e.g., 1.5, 0.5)
- Convert validated float exponents to `int` before proceeding
- Update docstring to document the new behavior
Reviewed By: hsharma35, mcremon-meta
Differential Revision: D1006956541 parent 75c677f commit db78fae
2 files changed
Lines changed: 15 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2266 | 2266 | | |
2267 | 2267 | | |
2268 | 2268 | | |
2269 | | - | |
| 2269 | + | |
| 2270 | + | |
2270 | 2271 | | |
2271 | 2272 | | |
2272 | 2273 | | |
2273 | 2274 | | |
2274 | 2275 | | |
2275 | 2276 | | |
2276 | 2277 | | |
2277 | | - | |
2278 | | - | |
| 2278 | + | |
| 2279 | + | |
2279 | 2280 | | |
2280 | 2281 | | |
2281 | | - | |
| 2282 | + | |
| 2283 | + | |
| 2284 | + | |
| 2285 | + | |
| 2286 | + | |
| 2287 | + | |
2282 | 2288 | | |
2283 | 2289 | | |
2284 | 2290 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1926 | 1926 | | |
1927 | 1927 | | |
1928 | 1928 | | |
1929 | | - | |
1930 | | - | |
| 1929 | + | |
| 1930 | + | |
1931 | 1931 | | |
1932 | 1932 | | |
1933 | 1933 | | |
| |||
1956 | 1956 | | |
1957 | 1957 | | |
1958 | 1958 | | |
1959 | | - | |
| 1959 | + | |
1960 | 1960 | | |
1961 | 1961 | | |
1962 | 1962 | | |
1963 | 1963 | | |
1964 | 1964 | | |
1965 | 1965 | | |
| 1966 | + | |
| 1967 | + | |
1966 | 1968 | | |
1967 | 1969 | | |
1968 | 1970 | | |
| |||
0 commit comments