[flang-commits] [flang] 2372249 - [fir] Remove obsolete fir.negf and fir.modf ops

Valentin Clement via flang-commits flang-commits at lists.llvm.org
Fri Oct 1 07:11:45 PDT 2021


Author: Eric Schweitz
Date: 2021-10-01T16:11:36+02:00
New Revision: 2372249d8689928a8d4a59baed3671613743653a

URL: https://github.com/llvm/llvm-project/commit/2372249d8689928a8d4a59baed3671613743653a
DIFF: https://github.com/llvm/llvm-project/commit/2372249d8689928a8d4a59baed3671613743653a.diff

LOG: [fir] Remove obsolete fir.negf and fir.modf ops

fir.negf op is replaced by mlir.negf and
fir.modf is just deleted.

Reviewed By: kiranchandramohan

Differential Revision: https://reviews.llvm.org/D110932

Co-authored-by: Jean Perier <jperier at nvidia.com>
Co-authored-by: Valentin Clement <clementval at gmail.com>

Added: 
    

Modified: 
    flang/include/flang/Optimizer/Dialect/FIROps.td
    flang/lib/Lower/IntrinsicCall.cpp
    flang/test/Fir/fir-ops.fir

Removed: 
    


################################################################################
diff  --git a/flang/include/flang/Optimizer/Dialect/FIROps.td b/flang/include/flang/Optimizer/Dialect/FIROps.td
index d487bd17ec1f9..264b8963d6e9c 100644
--- a/flang/include/flang/Optimizer/Dialect/FIROps.td
+++ b/flang/include/flang/Optimizer/Dialect/FIROps.td
@@ -2425,18 +2425,6 @@ class fir_UnaryArithmeticOp<string mnemonic, list<OpTrait> traits = []> :
   let printer = [{ return printUnaryOp(this->getOperation(), p); }];
 }
 
-class RealUnaryArithmeticOp<string mnemonic, list<OpTrait> traits = []> :
-      fir_UnaryArithmeticOp<mnemonic, traits>,
-      Arguments<(ins AnyRealLike:$operand)>;
-
-def fir_NegfOp : RealUnaryArithmeticOp<"negf">;
-
-class RealArithmeticOp<string mnemonic, list<OpTrait> traits = []> :
-      fir_ArithmeticOp<mnemonic, traits>,
-      Arguments<(ins AnyRealLike:$lhs, AnyRealLike:$rhs)>;
-
-def fir_ModfOp : RealArithmeticOp<"modf">;
-
 def fir_ConstcOp : fir_Op<"constc", [NoSideEffect]> {
   let summary = "create a complex constant";
 

diff  --git a/flang/lib/Lower/IntrinsicCall.cpp b/flang/lib/Lower/IntrinsicCall.cpp
index 5ef6b4d7e057e..3ced3ad3f3d09 100644
--- a/flang/lib/Lower/IntrinsicCall.cpp
+++ b/flang/lib/Lower/IntrinsicCall.cpp
@@ -1021,7 +1021,7 @@ mlir::Value IntrinsicLibrary::genConjg(mlir::Type resultType,
   auto imag =
       Fortran::lower::ComplexExprHelper{builder, loc}.extractComplexPart(
           cplx, /*isImagPart=*/true);
-  auto negImag = builder.create<fir::NegfOp>(loc, imag);
+  auto negImag = builder.create<mlir::NegFOp>(loc, imag);
   return Fortran::lower::ComplexExprHelper{builder, loc}.insertComplexPart(
       cplx, negImag, /*isImagPart=*/true);
 }
@@ -1187,7 +1187,7 @@ mlir::Value IntrinsicLibrary::genSign(mlir::Type resultType,
   // TODO: Requirements when second argument is +0./0.
   auto zeroAttr = builder.getZeroAttr(resultType);
   auto zero = builder.create<mlir::ConstantOp>(loc, resultType, zeroAttr);
-  auto neg = builder.create<fir::NegfOp>(loc, abs);
+  auto neg = builder.create<mlir::NegFOp>(loc, abs);
   auto cmp = builder.create<mlir::CmpFOp>(loc, mlir::CmpFPredicate::OLT,
                                           args[1], zero);
   return builder.create<mlir::SelectOp>(loc, cmp, neg, abs);

diff  --git a/flang/test/Fir/fir-ops.fir b/flang/test/Fir/fir-ops.fir
index 21f3755c4e35e..e64cff7a294fb 100644
--- a/flang/test/Fir/fir-ops.fir
+++ b/flang/test/Fir/fir-ops.fir
@@ -491,23 +491,21 @@ func @arith_real(%a : f128, %b : f128) -> f128 {
 
 // CHECK: [[VAL_171:%.*]] = constant 1.0
 // CHECK: [[VAL_172:%.*]] = fir.convert [[VAL_171]] : (f32) -> f128
-// CHECK: [[VAL_173:%.*]] = fir.negf [[VAL_169]] : f128
+// CHECK: [[VAL_173:%.*]] = negf [[VAL_169]] : f128
 // CHECK: [[VAL_174:%.*]] = addf [[VAL_172]], [[VAL_173]] : f128
 // CHECK: [[VAL_175:%.*]] = subf [[VAL_174]], [[VAL_170]] : f128
 // CHECK: [[VAL_176:%.*]] = mulf [[VAL_173]], [[VAL_175]] : f128
 // CHECK: [[VAL_177:%.*]] = divf [[VAL_176]], [[VAL_169]] : f128
-// CHECK: [[VAL_178:%.*]] = fir.modf [[VAL_177]], [[VAL_170]] : f128
   %c1 = constant 1.0 : f32
   %0 = fir.convert %c1 : (f32) -> f128
-  %1 = fir.negf %a : f128
+  %1 = negf %a : f128
   %2 = addf %0, %1 : f128
   %3 = subf %2, %b : f128
   %4 = mulf %1, %3 : f128
   %5 = divf %4, %a : f128
-  %6 = fir.modf %5, %b : f128
-// CHECK: return [[VAL_178]] : f128
+// CHECK: return [[VAL_177]] : f128
 // CHECK: }
-  return %6 : f128
+  return %5 : f128
 }
 
 // CHECK-LABEL: func @arith_complex(


        


More information about the flang-commits mailing list