|
1 | | -; RUN: %opt < %s %loadEnzyme -enzyme -enzyme_preopt=false -mem2reg -sroa -simplifycfg -instsimplify -gvn -adce -S | FileCheck %s |
| 1 | +; RUN: %opt < %s %loadEnzyme -enzyme -enzyme_preopt=false -mem2reg -sroa -simplifycfg -adce -S | FileCheck %s |
2 | 2 |
|
3 | 3 | define void @derivative(i64* %ptr, i64* %ptrp) { |
4 | 4 | entry: |
@@ -38,22 +38,43 @@ declare double @__enzyme_autodiff(i8*, ...) |
38 | 38 | ; CHECK-NEXT: %[[ptr3ipge:.+]] = getelementptr inbounds i64, i64* %"ptr'", i64 3 |
39 | 39 | ; CHECK-NEXT: %ptr3 = getelementptr inbounds i64, i64* %ptr, i64 3 |
40 | 40 | ; CHECK-NEXT: store i64 %loadnotype, i64* %ptr3 |
41 | | -; CHECK-NEXT: %[[cptr4ipge:.+]] = getelementptr inbounds i64, i64* %"ptr'", i64 4 |
42 | | -; CHECK-NEXT: %cptr4 = getelementptr inbounds i64, i64* %ptr, i64 4 |
43 | | -; CHECK-NEXT: store i64 %loadnotype, i64* %cptr4{{(, align 4)?}}, !tbaa !0 |
44 | | -; CHECK-NEXT: %0 = load i64, i64* %"cptr4'ipg" |
| 41 | +; CHECK-NEXT: %"cast'ipc" = bitcast i64* %"ptr'" to <2 x float>* |
| 42 | +; CHECK-NEXT: %cast = bitcast i64* %ptr to <2 x float>* |
| 43 | +; CHECK-NEXT: %"cast2'ipc" = bitcast <2 x float>* %"cast'ipc" to i64* |
| 44 | +; CHECK-NEXT: %cast2 = bitcast <2 x float>* %cast to i64* |
| 45 | +; CHECK-NEXT: %"cptr2'ipg" = getelementptr inbounds i64, i64* %"cast2'ipc", i64 2 |
| 46 | +; CHECK-NEXT: %cptr2 = getelementptr inbounds i64, i64* %cast2, i64 2 |
| 47 | +; CHECK-NEXT: %loadtype = load i64, i64* %cptr2, align 4 |
| 48 | +; CHECK-NEXT: %[[cptr4ipge:.+]] = getelementptr inbounds i64, i64* %"cast2'ipc", i64 4 |
| 49 | +; CHECK-NEXT: %cptr4 = getelementptr inbounds i64, i64* %cast2, i64 4 |
| 50 | +; CHECK-NEXT: store i64 %loadtype, i64* %cptr4{{(, align 4)?}}, !tbaa !0 |
| 51 | +; CHECK-NEXT: %[[lcptr4:.+]] = load i64, i64* %"cptr4'ipg" |
45 | 52 | ; CHECK-NEXT: store i64 0, i64* %"cptr4'ipg" |
46 | | -; CHECK-NEXT: %1 = load i64, i64* %"ptr2'ipg" |
47 | | -; CHECK-NEXT: %2 = bitcast i64 %0 to double |
48 | | -; CHECK-NEXT: %3 = bitcast i64 %1 to double |
49 | | -; CHECK-NEXT: %4 = fadd fast double %3, %2 |
50 | | -; CHECK-NEXT: %5 = bitcast double %4 to i64 |
51 | | -; CHECK-NEXT: store i64 %5, i64* %"ptr2'ipg" |
52 | | -; CHECK-NEXT: %6 = load i64, i64* %"ptr3'ipg" |
| 53 | + |
| 54 | +; CHECK-NEXT: %[[zerod:.+]] = bitcast i64 0 to double |
| 55 | +; CHECK-NEXT: %[[dder:.+]] = bitcast i64 %[[lcptr4]] to double |
| 56 | +; CHECK-NEXT: %[[same:.+]] = fadd fast double %[[zerod]], %[[dder]] |
| 57 | +; CHECK-NEXT: %[[backlcptr4:.+]] = bitcast double %[[same]] to i64 |
| 58 | + |
| 59 | +; CHECK-NEXT: %[[lcptr2:.+]] = load i64, i64* %"cptr2'ipg" |
| 60 | +; CHECK-NEXT: %[[bcptr2:.+]] = bitcast i64 %[[lcptr2]] to double |
| 61 | +; CHECK-NEXT: %[[bcptr4:.+]] = bitcast i64 %[[backlcptr4]] to double |
| 62 | +; CHECK-NEXT: %[[mmadd:.+]] = fadd fast double %[[bcptr2]], %[[bcptr4]] |
| 63 | +; CHECK-NEXT: %[[cbadd:.+]] = bitcast double %[[mmadd]] to i64 |
| 64 | +; CHECK-NEXT: store i64 %[[cbadd]], i64* %"cptr2'ipg" |
| 65 | +; CHECK-NEXT: %[[lptr3:.+]] = load i64, i64* %"ptr3'ipg" |
53 | 66 | ; CHECK-NEXT: store i64 0, i64* %"ptr3'ipg" |
54 | | -; CHECK-NEXT: %7 = bitcast i64 %6 to double |
55 | | -; CHECK-NEXT: %8 = fadd fast double %4, %7 |
56 | | -; CHECK-NEXT: %9 = bitcast double %8 to i64 |
57 | | -; CHECK-NEXT: store i64 %9, i64* %"ptr2'ipg" |
| 67 | + |
| 68 | +; CHECK-NEXT: %[[zerod2:.+]] = bitcast i64 0 to double |
| 69 | +; CHECK-NEXT: %[[bczd:.+]] = bitcast i64 %[[lptr3]] to double |
| 70 | +; CHECK-NEXT: %[[fasd:.+]] = fadd fast double %[[zerod2]], %[[bczd]] |
| 71 | +; CHECK-NEXT: %[[nlptr3:.+]] = bitcast double %[[fasd]] to i64 |
| 72 | + |
| 73 | +; CHECK-NEXT: %[[lptr2:.+]] = load i64, i64* %"ptr2'ipg" |
| 74 | +; CHECK-NEXT: %[[dptr2:.+]] = bitcast i64 %[[lptr2]] to double |
| 75 | +; CHECK-NEXT: %[[dptr3:.+]] = bitcast i64 %[[nlptr3]] to double |
| 76 | +; CHECK-NEXT: %[[ladd:.+]] = fadd fast double %[[dptr2]], %[[dptr3]] |
| 77 | +; CHECK-NEXT: %[[fs:.+]] = bitcast double %[[ladd]] to i64 |
| 78 | +; CHECK-NEXT: store i64 %[[fs]], i64* %"ptr2'ipg" |
58 | 79 | ; CHECK-NEXT: ret void |
59 | 80 | ; CHECK-NEXT: } |
0 commit comments