|
| 1 | +; RUN: %opt < %s %loadEnzyme -enzyme -enzyme-preopt=false -mem2reg -simplifycfg -early-cse -instcombine -S | FileCheck %s |
| 2 | + |
| 3 | +declare {float, float, float} @__enzyme_fwddiff({float, float, float} (<4 x float>)*, <4 x float>, <4 x float>) |
| 4 | + |
| 5 | +define {float, float, float} @square(<4 x float> %x) { |
| 6 | +entry: |
| 7 | + %vec = insertelement <4 x float> %x, float 1.0, i32 3 |
| 8 | + %sq = fmul <4 x float> %x, %x |
| 9 | + %cb = fmul <4 x float> %sq, %x |
| 10 | + %id = shufflevector <4 x float> %sq, <4 x float> %cb, <4 x i32> <i32 0, i32 1, i32 4, i32 5> |
| 11 | + %res1 = extractelement <4 x float> %id, i32 1 |
| 12 | + %res2 = extractelement <4 x float> %id, i32 2 |
| 13 | + %res3 = extractelement <4 x float> %id, i32 3 |
| 14 | + %agg1 = insertvalue {float, float, float} undef, float %res1, 0 |
| 15 | + %agg2 = insertvalue {float, float, float} %agg1, float %res2, 1 |
| 16 | + %agg3 = insertvalue {float, float, float} %agg2, float %res3, 2 |
| 17 | + ret {float, float, float} %agg3 |
| 18 | +} |
| 19 | + |
| 20 | +define {float, float, float} @dsquare(<4 x float> %x) { |
| 21 | +entry: |
| 22 | + %call = tail call {float, float, float} @__enzyme_fwddiff({float, float, float} (<4 x float>)* @square, <4 x float> %x, <4 x float> <float 1.0, float 1.0, float 1.0, float 1.0>) |
| 23 | + ret {float, float, float} %call |
| 24 | +} |
| 25 | + |
| 26 | + |
| 27 | +; CHECK: define internal { float, float, float } @fwddiffesquare(<4 x float> %x, <4 x float> %"x'") |
| 28 | +; CHECK-NEXT: entry: |
| 29 | +; CHECK-NEXT: %sq = fmul <4 x float> %x, %x |
| 30 | +; CHECK-NEXT: %0 = fmul fast <4 x float> %"x'", %x |
| 31 | +; CHECK-NEXT: %1 = fadd fast <4 x float> %0, %0 |
| 32 | +; CHECK-NEXT: %2 = fmul fast <4 x float> %1, %x |
| 33 | +; CHECK-NEXT: %3 = fmul fast <4 x float> %sq, %"x'" |
| 34 | +; CHECK-NEXT: %4 = fadd fast <4 x float> %2, %3 |
| 35 | +; CHECK-NEXT: %5 = extractelement <4 x float> %1, i32 1 |
| 36 | +; CHECK-NEXT: %6 = extractelement <4 x float> %4, i32 0 |
| 37 | +; CHECK-NEXT: %7 = extractelement <4 x float> %4, i32 1 |
| 38 | +; CHECK-NEXT: %8 = insertvalue { float, float, float } zeroinitializer, float %5, 0 |
| 39 | +; CHECK-NEXT: %9 = insertvalue { float, float, float } %8, float %6, 1 |
| 40 | +; CHECK-NEXT: %10 = insertvalue { float, float, float } %9, float %7, 2 |
| 41 | +; CHECK-NEXT: ret { float, float, float } %10 |
| 42 | +; CHECK-NEXT: } |
0 commit comments