Commit 7433600
committed
feat: lower atan2, quotient and logical_xor in the native Expr compiler
Closes the binary/compare cluster on the Expr op-coverage checklist
(#188). Two new IR opcodes — `arctan2` (111) and `floor_divide` (112)
— plus a dedicated `logical_xor` lower clause.
- `atan2` slots into `@arith_binary` as `atan2: :arctan2`. The shared
handler casts both operands to out.type and emits the binary op,
matching Emily.Backend.atan2/3 (@renamed_arith_binary) bit-for-bit.
- `quotient` joins `@arith_binary` as `quotient: :floor_divide` —
Emily.Backend.quotient/3 is exactly `floor_divide(astype(a, out.type),
astype(b, out.type))`, which is what the shared handler does with the
floor_divide opcode.
- `logical_xor` (no MLX primitive) gets a dedicated composite clause
that mirrors Emily.Backend.logical_xor/3 — `(a != 0) != (b != 0)`
using three not_equal emits over a pair of per-dtype scalar zeros,
with the trailing coerce producing {:u, 8}.
Probe drops from 18 → 15 misses. Equivalence tests cover atan2 over
the four quadrants + axis boundaries, quotient over s32/s64/u8/u32,
and logical_xor over the four truth-table corners for both float and
integer dtypes (asserting the {:u, 8} predicate dtype after coerce).1 parent 5747a68 commit 7433600
4 files changed
Lines changed: 94 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
61 | 69 | | |
62 | 70 | | |
63 | 71 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
201 | 201 | | |
202 | 202 | | |
203 | 203 | | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
204 | 210 | | |
205 | 211 | | |
206 | | - | |
| 212 | + | |
207 | 213 | | |
208 | 214 | | |
209 | 215 | | |
| |||
752 | 758 | | |
753 | 759 | | |
754 | 760 | | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
755 | 768 | | |
756 | 769 | | |
757 | 770 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
182 | 182 | | |
183 | 183 | | |
184 | 184 | | |
185 | | - | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
186 | 192 | | |
187 | 193 | | |
188 | 194 | | |
| |||
281 | 287 | | |
282 | 288 | | |
283 | 289 | | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
284 | 293 | | |
285 | 294 | | |
286 | 295 | | |
287 | 296 | | |
288 | 297 | | |
289 | 298 | | |
290 | 299 | | |
| 300 | + | |
291 | 301 | | |
292 | 302 | | |
| 303 | + | |
293 | 304 | | |
294 | 305 | | |
295 | 306 | | |
| |||
434 | 445 | | |
435 | 446 | | |
436 | 447 | | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
437 | 463 | | |
438 | 464 | | |
439 | 465 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
170 | 170 | | |
171 | 171 | | |
172 | 172 | | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
173 | 202 | | |
174 | 203 | | |
175 | 204 | | |
| |||
192 | 221 | | |
193 | 222 | | |
194 | 223 | | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
195 | 240 | | |
196 | 241 | | |
197 | 242 | | |
| |||
0 commit comments