forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
handle indirect enzyme_const loads (rust-lang#753)
* add testcase for enzyme loads behind phis * handle load trough phis * adjust test for older llvms * adjust test for older llvms * adjust test for even older llvms
- Loading branch information
Showing
2 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
; RUN: %opt < %s %loadEnzyme -enzyme -enzyme-preopt=false -mem2reg -sroa -instsimplify -simplifycfg -S | FileCheck %s | ||
|
||
; ModuleID = 'ld-temp.o' | ||
source_filename = "ld-temp.o" | ||
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" | ||
target triple = "x86_64-unknown-linux-gnu" | ||
|
||
@enzyme_const = internal global i32 0, align 4 | ||
|
||
define internal double @callable(double* %x) { | ||
ret double 1.000000e+00 | ||
} | ||
|
||
define internal void @_Z19testSensitivitiesADv(double* %primal, double* %grad, double* %a) { | ||
br label %bb1 | ||
|
||
bb1: | ||
%a1 = load i32, i32* @enzyme_const, align 4 | ||
br label %bb3 | ||
|
||
bb2: | ||
%a2 = load i32, i32* @enzyme_const, align 4 | ||
br label %bb3 | ||
|
||
bb3: | ||
%a3 = phi i32 [ %a1, %bb1 ], [ %a2, %bb2 ] | ||
;%a3 = load i32, i32* @enzyme_const, align 4 | ||
|
||
%c1 = call double (...) @__enzyme_autodiff(i8* bitcast (double (double*)* @callable to i8*), i32 %a3, double* %a) | ||
ret void | ||
} | ||
declare dso_local double @__enzyme_autodiff(...) | ||
|
||
; CHECK: define internal void @diffecallable(double* %x, double %differeturn) | ||
; CHECK-NEXT: invert: | ||
; CHECK-NEXT: ret void | ||
; CHECK-NEXT: } |