File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -2084,6 +2084,10 @@ LogicalResult cir::ComplexImagOp::verify() {
20842084}
20852085
20862086OpFoldResult cir::ComplexImagOp::fold (FoldAdaptor adaptor) {
2087+   if  (auto  complexCreateOp =
2088+           dyn_cast_or_null<cir::ComplexCreateOp>(getOperand ().getDefiningOp ()))
2089+     return  complexCreateOp.getOperand (1 );
2090+ 
20872091  auto  complex  =
20882092      mlir::cast_if_present<cir::ConstComplexAttr>(adaptor.getOperand ());
20892093  return  complex  ? complex .getImag () : 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 -split-input-file - o - | FileCheck %s
22
33!s32i = !cir.int<s, 32>
44
@@ -21,3 +21,19 @@ module {
2121  // CHECK: }
2222
2323}
24+ 
25+ // -----
26+ 
27+ !s32i = !cir.int<s, 32>
28+ 
29+ module {
30+   cir.func dso_local @fold_complex_imag_from_create_test(%arg0: !s32i, %arg1: !s32i) -> !s32i {
31+     %0 = cir.complex.create %arg0, %arg1 : !s32i -> !cir.complex<!s32i>
32+     %1 = cir.complex.imag %0 : !cir.complex<!s32i> -> !s32i
33+     cir.return %1 : !s32i
34+   }
35+ 
36+   // CHECK: cir.func dso_local @fold_complex_imag_from_create_test(%[[ARG_0:.*]]: !s32i, %[[ARG_1:.*]]: !s32i) -> !s32i {
37+   // CHECK:   cir.return %[[ARG_1]] : !s32i
38+   // CHECK: }
39+ }
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments