File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -2066,6 +2066,11 @@ LogicalResult cir::ComplexRealOp::verify() {
2066
2066
}
2067
2067
2068
2068
OpFoldResult cir::ComplexRealOp::fold (FoldAdaptor adaptor) {
2069
+ if (auto complexCreateOp = dyn_cast_or_null<cir::ComplexCreateOp>(
2070
+ getOperand ().getDefiningOp ())) {
2071
+ return complexCreateOp.getOperand (0 );
2072
+ }
2073
+
2069
2074
auto complex =
2070
2075
mlir::cast_if_present<cir::ConstComplexAttr>(adaptor.getOperand ());
2071
2076
return complex ? complex.getReal () : nullptr ;
Original file line number Diff line number Diff line change 1
- // RUN: cir-opt %s -cir-canonicalize -o - | FileCheck %s
1
+ // RUN: cir-opt %s -cir-canonicalize -o - -split-input-file | FileCheck %s
2
2
3
3
!s32i = !cir.int<s, 32>
4
4
@@ -21,3 +21,19 @@ module {
21
21
// CHECK: }
22
22
23
23
}
24
+
25
+ // -----
26
+
27
+ !s32i = !cir.int<s, 32>
28
+
29
+ module {
30
+ cir.func dso_local @fold_complex_real_from_create_test(%arg0: !s32i, %arg1: !s32i) -> !s32i {
31
+ %0 = cir.complex.create %arg0, %arg1 : !s32i -> !cir.complex<!s32i>
32
+ %1 = cir.complex.real %0 : !cir.complex<!s32i> -> !s32i
33
+ cir.return %1 : !s32i
34
+ }
35
+
36
+ // CHECK: cir.func dso_local @fold_complex_real_from_create_test(%[[ARG_0:.*]]: !s32i, %[[ARG_1:.*]]: !s32i) -> !s32i {
37
+ // CHECK: cir.return %[[ARG_0]] : !s32i
38
+ // CHECK: }
39
+ }
You can’t perform that action at this time.
0 commit comments