Skip to content

Commit 47c07ed

Browse files
committed
[NFC] simplify matching
1 parent f4c2978 commit 47c07ed

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

compiler/rustc_codegen_llvm/src/builder/autodiff.rs

+3-12
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,6 @@ fn generate_enzyme_call<'ll>(
150150
outer_fn: &'ll Value,
151151
attrs: AutoDiffAttrs,
152152
) {
153-
let inputs = attrs.input_activity;
154-
let output = attrs.ret_activity;
155-
156153
// We have to pick the name depending on whether we want forward or reverse mode autodiff.
157154
let mut ad_name: String = match attrs.mode {
158155
DiffMode::Forward => "__enzyme_fwddiff",
@@ -240,18 +237,12 @@ fn generate_enzyme_call<'ll>(
240237
args.push(fn_to_diff);
241238

242239
let enzyme_primal_ret = cx.create_metadata("enzyme_primal_return".to_string()).unwrap();
243-
match output {
244-
DiffActivity::Dual => {
245-
args.push(cx.get_metadata_value(enzyme_primal_ret));
246-
}
247-
DiffActivity::Active => {
248-
args.push(cx.get_metadata_value(enzyme_primal_ret));
249-
}
250-
_ => {}
240+
if matches!(attrs.ret_activity, DiffActivity::Dual | DiffActivity::Active) {
241+
args.push(cx.get_metadata_value(enzyme_primal_ret));
251242
}
252243

253244
let outer_args: Vec<&llvm::Value> = get_params(outer_fn);
254-
match_args_from_caller_to_enzyme(&cx, &mut args, &inputs, &outer_args);
245+
match_args_from_caller_to_enzyme(&cx, &mut args, &attrs.input_activity, &outer_args);
255246

256247
let call = builder.call(enzyme_ty, ad_fn, &args, None);
257248

0 commit comments

Comments
 (0)