28 lines · plain
1// RUN: mlir-opt %s --irdl-file=%S/cmath.irdl.mlir | mlir-opt --irdl-file=%S/cmath.irdl.mlir | FileCheck %s2 3module {4 // CHECK: func.func @conorm(%[[p:[^:]*]]: !cmath.complex<f32>, %[[q:[^:]*]]: !cmath.complex<f32>) -> f32 {5 // CHECK: %[[norm_p:[^ ]*]] = "cmath.norm"(%[[p]]) : (!cmath.complex<f32>) -> f326 // CHECK: %[[norm_q:[^ ]*]] = "cmath.norm"(%[[q]]) : (!cmath.complex<f32>) -> f327 // CHECK: %[[pq:[^ ]*]] = arith.mulf %[[norm_p]], %[[norm_q]] : f328 // CHECK: return %[[pq]] : f329 // CHECK: }10 func.func @conorm(%p: !cmath.complex<f32>, %q: !cmath.complex<f32>) -> f32 {11 %norm_p = "cmath.norm"(%p) : (!cmath.complex<f32>) -> f3212 %norm_q = "cmath.norm"(%q) : (!cmath.complex<f32>) -> f3213 %pq = arith.mulf %norm_p, %norm_q : f3214 return %pq : f3215 }16 17 // CHECK: func.func @conorm2(%[[p:[^:]*]]: !cmath.complex<f32>, %[[q:[^:]*]]: !cmath.complex<f32>) -> f32 {18 // CHECK: %[[pq:[^ ]*]] = "cmath.mul"(%[[p]], %[[q]]) : (!cmath.complex<f32>, !cmath.complex<f32>) -> !cmath.complex<f32>19 // CHECK: %[[conorm:[^ ]*]] = "cmath.norm"(%[[pq]]) : (!cmath.complex<f32>) -> f3220 // CHECK: return %[[conorm]] : f3221 // CHECK: }22 func.func @conorm2(%p: !cmath.complex<f32>, %q: !cmath.complex<f32>) -> f32 {23 %pq = "cmath.mul"(%p, %q) : (!cmath.complex<f32>, !cmath.complex<f32>) -> !cmath.complex<f32>24 %conorm = "cmath.norm"(%pq) : (!cmath.complex<f32>) -> f3225 return %conorm : f3226 }27}28