@@ -550,23 +550,28 @@ pub(crate) unsafe fn llvm_optimize(
550
550
let unroll_loops;
551
551
let vectorize_slp;
552
552
let vectorize_loop;
553
+ let run_enzyme;
553
554
554
- let run_enzyme = cfg ! ( llvm_enzyme) ;
555
555
// When we build rustc with enzyme/autodiff support, we want to postpone size-increasing
556
- // optimizations until after differentiation. FIXME(ZuseZ4): Before shipping on nightly,
556
+ // optimizations until after differentiation. Our pipeline is thus: (opt + enzyme), (full opt).
557
+ // We therefore have two calls to llvm_optimize, if autodiff is used.
558
+ //
559
+ // FIXME(ZuseZ4): Before shipping on nightly,
557
560
// we should make this more granular, or at least check that the user has at least one autodiff
558
561
// call in their code, to justify altering the compilation pipeline.
559
- if skip_size_increasing_opts && run_enzyme {
562
+ if skip_size_increasing_opts && cfg ! ( llvm_enzyme ) {
560
563
unroll_loops = false ;
561
564
vectorize_slp = false ;
562
565
vectorize_loop = false ;
566
+ run_enzyme = true ;
563
567
} else {
564
568
unroll_loops =
565
569
opt_level != config:: OptLevel :: Size && opt_level != config:: OptLevel :: SizeMin ;
566
570
vectorize_slp = config. vectorize_slp ;
567
571
vectorize_loop = config. vectorize_loop ;
572
+ run_enzyme = false ;
568
573
}
569
- trace ! ( ?unroll_loops, ?vectorize_slp, ?vectorize_loop) ;
574
+ trace ! ( ?unroll_loops, ?vectorize_slp, ?vectorize_loop, ?run_enzyme ) ;
570
575
let using_thin_buffers = opt_stage == llvm:: OptStage :: PreLinkThinLTO || config. bitcode_needed ( ) ;
571
576
let pgo_gen_path = get_pgo_gen_path ( config) ;
572
577
let pgo_use_path = get_pgo_use_path ( config) ;
0 commit comments