Run enabled passes over one function to a fixpoint (folding + DCE alternate).
(func: &mut IrFunction, opts: OptOptions)
| 44 | optimize_function(func, opts); |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | // Run enabled passes over one function to a fixpoint (folding + DCE alternate). |
| 49 | fn optimize_function(func: &mut IrFunction, opts: OptOptions) { |
| 50 | const MAX_ROUNDS: usize = 16; |
| 51 | for _ in 0..MAX_ROUNDS { |
| 52 | let mut changed = false; |
| 53 | if opts.phi_simplify { |
| 54 | changed |= phi::run(func); |
| 55 | } |
| 56 | if opts.const_fold { |
| 57 | changed |= const_fold::run(func); |
| 58 | } |
| 59 | if opts.dce { |
| 60 | changed |= dce::run(func); |
| 61 | } |
| 62 | if !changed { |
| 63 | break; |