Files
clang-p2996/mlir/test/Dialect/Complex/invalid.mlir
Matthias Springer 192439db6e [mlir][Complex] Fix bug in MergeComplexBitcast (#74271)
When two `complex.bitcast` ops are folded and the resulting bitcast is a
non-complex -> non-complex bitcast, an `arith.bitcast` should be
generated. Otherwise, the generated `complex.bitcast` op is invalid.

Also remove a pattern that convertes non-complex -> non-complex
`complex.bitcast` ops to `arith.bitcast`. Such `complex.bitcast` ops are
invalid and should not appear in the input.

Note: This bug can only be triggered by running with `-debug` (which
will should intermediate IR that does not verify) or with
`MLIR_ENABLE_EXPENSIVE_PATTERN_API_CHECKS` (#74270).
2023-12-05 10:25:19 +09:00

32 lines
1.0 KiB
MLIR

// RUN: mlir-opt -split-input-file %s -verify-diagnostics
func.func @complex_constant_wrong_array_attribute_length() {
// expected-error @+1 {{requires 'value' to be a complex constant, represented as array of two values}}
%0 = complex.constant [1.0 : f32] : complex<f32>
return
}
// -----
func.func @complex_constant_wrong_element_types() {
// expected-error @+1 {{requires attribute's element types ('f32', 'f32') to match the element type of the op's return type ('f64')}}
%0 = complex.constant [1.0 : f32, -1.0 : f32] : complex<f64>
return
}
// -----
func.func @complex_constant_two_different_element_types() {
// expected-error @+1 {{requires attribute's element types ('f32', 'f64') to match the element type of the op's return type ('f64')}}
%0 = complex.constant [1.0 : f32, -1.0 : f64] : complex<f64>
return
}
// -----
func.func @complex_bitcast_i64(%arg0 : i64) {
// expected-error @+1 {{op requires that either input or output has a complex type}}
%0 = complex.bitcast %arg0: i64 to f64
return
}