CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
99 lines
4.5 KiB
Plaintext
99 lines
4.5 KiB
Plaintext
// Test regrouping of + and - operations on complex components into complex operations
|
|
// RUN: fir-opt --canonicalize %s | FileCheck %s
|
|
|
|
|
|
// CHECK-LABEL: @add
|
|
func.func @add(%z: !fir.ref<complex<f64>>, %z1 : complex<f64>, %z2 : complex<f64>) {
|
|
%c0 = arith.constant 0 : index
|
|
%c1 = arith.constant 1 : index
|
|
%real1 = fir.extract_value %z1, [0 : index] : (complex<f64>) -> f64
|
|
%imag1 = fir.extract_value %z1, [1 : index] : (complex<f64>) -> f64
|
|
%real2 = fir.extract_value %z2, [0 : index] : (complex<f64>) -> f64
|
|
%imag2 = fir.extract_value %z2, [1 : index] : (complex<f64>) -> f64
|
|
|
|
// CHECK-LABEL: fir.addc
|
|
%real = arith.addf %real1, %real2 : f64
|
|
%imag = arith.addf %imag1, %imag2 : f64
|
|
%undef = fir.undefined complex<f64>
|
|
%insert_real = fir.insert_value %undef, %real, [0 : index] : (complex<f64>, f64) -> complex<f64>
|
|
%insert_imag = fir.insert_value %insert_real, %imag, [1 : index] : (complex<f64>, f64) -> complex<f64>
|
|
fir.store %insert_imag to %z : !fir.ref<complex<f64>>
|
|
return
|
|
}
|
|
|
|
// CHECK-LABEL: @sub
|
|
func.func @sub(%z: !fir.ref<complex<f64>>, %z1 : complex<f64>, %z2 : complex<f64>) {
|
|
%c0 = arith.constant 0 : index
|
|
%c1 = arith.constant 1 : index
|
|
%real1 = fir.extract_value %z1, [0 : index] : (complex<f64>) -> f64
|
|
%imag1 = fir.extract_value %z1, [1 : index] : (complex<f64>) -> f64
|
|
%real2 = fir.extract_value %z2, [0 : index] : (complex<f64>) -> f64
|
|
%imag2 = fir.extract_value %z2, [1 : index] : (complex<f64>) -> f64
|
|
|
|
// CHECK-LABEL: fir.subc
|
|
%real = arith.subf %real1, %real2 : f64
|
|
%imag = arith.subf %imag1, %imag2 : f64
|
|
%undef = fir.undefined complex<f64>
|
|
%insert_real = fir.insert_value %undef, %real, [0 : index] : (complex<f64>, f64) -> complex<f64>
|
|
%insert_imag = fir.insert_value %insert_real, %imag, [1 : index] : (complex<f64>, f64) -> complex<f64>
|
|
fir.store %insert_imag to %z : !fir.ref<complex<f64>>
|
|
return
|
|
}
|
|
|
|
// CHECK-LABEL: @undefOpHiddenByBranch
|
|
func.func @undefOpHiddenByBranch(%z: !fir.ref<complex<f64>>, %b: i1) {
|
|
%c0 = arith.constant 0 : index
|
|
%c1 = arith.constant 1 : index
|
|
cf.cond_br %b, ^bb1, ^bb2
|
|
^bb1: // pred: ^bb0
|
|
%u1 = fir.undefined complex<f64>
|
|
%z1l = fir.call @bar1() : () -> complex<f64>
|
|
%z1r = fir.call @bar1() : () -> complex<f64>
|
|
cf.br ^bb3(%u1, %z1l, %z1r : complex<f64>, complex<f64>, complex<f64>)
|
|
^bb2: // pred: ^bb0
|
|
%u2 = fir.undefined complex<f64>
|
|
%z2l = fir.call @bar2() : () -> complex<f64>
|
|
%z2r = fir.call @bar2() : () -> complex<f64>
|
|
cf.br ^bb3(%u2, %z2l, %z2r : complex<f64>, complex<f64>, complex<f64>)
|
|
|
|
// CHECK: ^bb3(%[[z1:.*]]: complex<f64>, %[[z2:.*]]: complex<f64>): // 2 preds: ^bb1, ^bb2
|
|
// CHECK: fir.addc %[[z1]], %[[z2]] : complex<f64>
|
|
|
|
^bb3(%undef : complex<f64>, %z1 : complex<f64>, %z2 : complex<f64>): // 2 preds: ^bb1, ^bb2
|
|
%real1 = fir.extract_value %z1, [0 : index] : (complex<f64>) -> f64
|
|
%imag1 = fir.extract_value %z1, [1 : index] : (complex<f64>) -> f64
|
|
%real2 = fir.extract_value %z2, [0 : index] : (complex<f64>) -> f64
|
|
%imag2 = fir.extract_value %z2, [1 : index] : (complex<f64>) -> f64
|
|
%real = arith.addf %real1, %real2 : f64
|
|
%imag = arith.addf %imag1, %imag2 : f64
|
|
%insert_real = fir.insert_value %undef, %real, [0 : index] : (complex<f64>, f64) -> complex<f64>
|
|
%insert_imag = fir.insert_value %insert_real, %imag, [1 : index] : (complex<f64>, f64) -> complex<f64>
|
|
fir.store %insert_imag to %z : !fir.ref<complex<f64>>
|
|
return
|
|
}
|
|
func.func private @bar1() -> complex<f64>
|
|
func.func private @bar2() -> complex<f64>
|
|
|
|
// CHECK-LABEL: @close_but_bad_pattern
|
|
func.func @close_but_bad_pattern(%z: !fir.ref<complex<f64>>, %z1 : complex<f64>, %z2 : complex<f64>) {
|
|
%c0 = arith.constant 0 : index
|
|
%c1 = arith.constant 1 : index
|
|
%real1 = fir.extract_value %z1, [0 : index] : (complex<f64>) -> f64
|
|
// extracting %c0 instead of %c1
|
|
%imag1 = fir.extract_value %z1, [0 : index] : (complex<f64>) -> f64
|
|
%real2 = fir.extract_value %z2, [0 : index] : (complex<f64>) -> f64
|
|
%imag2 = fir.extract_value %z2, [1 : index] : (complex<f64>) -> f64
|
|
// CHECK: arith.subf
|
|
// CHECK: subf
|
|
%real = arith.subf %real1, %real2 : f64
|
|
%imag = arith.subf %imag1, %imag2 : f64
|
|
%undef = fir.undefined complex<f64>
|
|
// CHECK: %[[insert1:.*]] = fir.insert_value %{{.*}}, %{{.*}}, [0
|
|
// CHECK: %[[insert2:.*]] = fir.insert_value %[[insert1]], %{{.*}}, [1
|
|
%insert_real = fir.insert_value %undef, %real, [0 : index] : (complex<f64>, f64) -> complex<f64>
|
|
%insert_imag = fir.insert_value %insert_real, %imag, [1 : index] : (complex<f64>, f64) -> complex<f64>
|
|
// CHECK: fir.store %[[insert2]] to {{.*}}
|
|
fir.store %insert_imag to %z : !fir.ref<complex<f64>>
|
|
return
|
|
}
|