Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement tgamma derivative #2140

Merged
merged 1 commit into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions enzyme/Enzyme/InstructionDerivatives.td
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,17 @@ def : CallPattern<(Op $x, $y),
[ReadNone, NoUnwind]
>;

def : CallPattern<(Op $x),
["tgamma"],
[
(
FMul (Call<(ArgAsRetTypesFunc<"digamma">), [ReadNone,NoUnwind]> $x), (DiffeRet)
)
],
(ForwardFromSummedReverse),
[ReadNone, NoUnwind]
>;

def : CallPattern<(Op $x),
["logabsgamma"],
[
Expand Down
9 changes: 9 additions & 0 deletions enzyme/test/Enzyme/ReverseMode/tgamma.ll
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,12 @@ declare double @tgamma(double)
; CHECK-NEXT: }

; CHECK: define internal fastcc { double } @diffea5(double %arg, double %differeturn)
; CHECK-NEXT: bb:
; CHECK-NEXT: %i8 = call double @tgamma(double %arg) #1
; CHECK-NEXT: %0 = fmul fast double %differeturn, %arg
; CHECK-NEXT: %1 = fmul fast double %i8, %differeturn
; CHECK-NEXT: %2 = call fast double @digamma(double %arg) #0
; CHECK-NEXT: %3 = fmul fast double %2, %0
; CHECK-NEXT: %4 = fadd fast double %1, %3
; CHECK-NEXT: %5 = insertvalue { double } undef, double %4, 0
; CHECK-NEXT: ret { double } %5
Loading