Anton Korobeynikov
42e530f9ab
Add tests
2025-02-24 15:20:46 -08:00
Erik Eckstein
7cceaff5f3
SIL: don't print operand types in textual SIL
...
Type annotations for instruction operands are omitted, e.g.
```
%3 = struct $S(%1, %2)
```
Operand types are redundant anyway and were only used for sanity checking in the SIL parser.
But: operand types _are_ printed if the definition of the operand value was not printed yet.
This happens:
* if the block with the definition appears after the block where the operand's instruction is located
* if a block or instruction is printed in isolation, e.g. in a debugger
The old behavior can be restored with `-Xllvm -sil-print-types`.
This option is added to many existing test files which check for operand types in their check-lines.
2024-11-21 18:49:52 +01:00
Anton Korobeynikov
a5e83817b2
Reapply "Implement several peephole optimizations to unblock further optimizations of autodiff code" with correctness fix ( #62012 )
...
* Implement several peephole optimizations to unblock further optimizations of autodiff code
1. Simplify differentiable_function_extract of differentiable_function.
Before:
%x = differentiable_function(%orig, %jvp, %vjp)
%y = differentiable_function_extract [original] %x
After:
%y = %orig
2. Push conversion instructions inside of differentiable_function.
This unblocks inlining and specialization.
Before:
%x = differentiable_function(%orig, %jvp, %vjp)
%y = convert_escape_to_noescape %x
After:
%orig' = convert_escape_to_noescape %orig
%jvp' = convert_escape_to_noescape %jvp
%vjp' = convert_escape_to_noescape %vjp
%y = differentiable_function(%orig', %jvp', %vjp')
3. Another peephole is needed for reordering function conversion instructions to enable full inlining:
(convert_escape_to_noescape (convert_function (thin_to_thick_function x)))
=>
(convert_escape_to_noescape (thin_to_thick_function (convert_function x)))
Co-authored-by: Dan Zheng <danielzheng@google.com >
2022-11-16 23:21:27 -08:00
Meghana Gupta
5e20112e0c
Revert "Implement several peephole optimizations to unblock further optimizations of autodiff code ( #60520 )"
...
This reverts commit 2f5492f572 .
2022-10-25 13:35:14 -07:00
Anton Korobeynikov
2f5492f572
Implement several peephole optimizations to unblock further optimizations of autodiff code ( #60520 )
...
* Implement several peephole optimizations to unblock further optimizations of autodiff code
1. Simplify differentiable_function_extract of differentiable_function.
Before:
%x = differentiable_function(%orig, %jvp, %vjp)
%y = differentiable_function_extract [original] %x
After:
%y = %orig
2. Push conversion instructions inside of differentiable_function.
This unblocks inlining and specialization.
Before:
%x = differentiable_function(%orig, %jvp, %vjp)
%y = convert_escape_to_noescape %x
After:
%orig' = convert_escape_to_noescape %orig
%jvp' = convert_escape_to_noescape %jvp
%vjp' = convert_escape_to_noescape %vjp
%y = differentiable_function(%orig', %jvp', %vjp')
3. Another peephole is needed for reordering function conversion instructions to enable full inlining:
(convert_escape_to_noescape (convert_function (thin_to_thick_function x)))
=>
(convert_escape_to_noescape (thin_to_thick_function (convert_function x)))
* Remove broken disabled folding transform:
- It is disabled
- It is broken
- It is certainly not something mandatory
Co-authored-by: Dan Zheng <danielzheng@google.com >
2022-09-26 09:44:04 -07:00