[flang-commits] [PATCH] D139520: [flang] add hlfir.no_reassoc definition

Jean Perier via Phabricator via flang-commits flang-commits at lists.llvm.org
Wed Dec 7 05:45:28 PST 2022


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG80e5ff775f8b: [flang] add hlfir.no_reassoc definition (authored by jeanPerier).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D139520/new/

https://reviews.llvm.org/D139520

Files:
  flang/include/flang/Optimizer/HLFIR/HLFIROps.h
  flang/include/flang/Optimizer/HLFIR/HLFIROps.td
  flang/test/HLFIR/no_reassoc.fir


Index: flang/test/HLFIR/no_reassoc.fir
===================================================================
--- /dev/null
+++ flang/test/HLFIR/no_reassoc.fir
@@ -0,0 +1,27 @@
+// Test hlfir.no_reassoc operation parse, verify (no errors), and unparse.
+
+// RUN: fir-opt %s | fir-opt | FileCheck %s
+
+func.func @no_reassoc_value(%arg0: i32) {
+  %0 = hlfir.no_reassoc %arg0 : i32
+  return
+}
+// CHECK-LABEL: func.func @no_reassoc_value(
+// CHECK-SAME:    %[[VAL_0:.*]]: i32) {
+// CHECK:   hlfir.no_reassoc %[[VAL_0]] : i32
+
+func.func @no_reassoc_var(%arg0: !fir.ref<i32>) {
+  %0 = hlfir.no_reassoc %arg0 : !fir.ref<i32>
+  return
+}
+// CHECK-LABEL: func.func @no_reassoc_var(
+// CHECK-SAME:    %[[VAL_0:.*]]: !fir.ref<i32>) {
+// CHECK:   hlfir.no_reassoc %[[VAL_0]] : !fir.ref<i32>
+
+func.func @no_reassoc_expr(%arg0: !hlfir.expr<10xi32>) {
+  %0 = hlfir.no_reassoc %arg0 : !hlfir.expr<10xi32>
+  return
+}
+// CHECK-LABEL: func.func @no_reassoc_expr(
+// CHECK-SAME:    %[[VAL_0:.*]]: !hlfir.expr<10xi32>) {
+// CHECK:   hlfir.no_reassoc %[[VAL_0]] : !hlfir.expr<10xi32>
Index: flang/include/flang/Optimizer/HLFIR/HLFIROps.td
===================================================================
--- flang/include/flang/Optimizer/HLFIR/HLFIROps.td
+++ flang/include/flang/Optimizer/HLFIR/HLFIROps.td
@@ -318,5 +318,18 @@
   let builders = [OpBuilder<(ins "mlir::Value":$var)>];
 }
 
+def hlfir_NoReassocOp : hlfir_Op<"no_reassoc", [NoMemoryEffect, SameOperandsAndResultType]> {
+  let summary = "synthetic op to prevent reassociation";
+
+  let description = [{
+    Same as fir.reassoc, except it accepts hlfir.expr arguments.
+  }];
+
+  let arguments = (ins AnyFortranEntity:$val);
+  let results = (outs AnyFortranEntity);
+
+  let assemblyFormat = "$val attr-dict `:` type($val)";
+}
+
 
 #endif // FORTRAN_DIALECT_HLFIR_OPS
Index: flang/include/flang/Optimizer/HLFIR/HLFIROps.h
===================================================================
--- flang/include/flang/Optimizer/HLFIR/HLFIROps.h
+++ flang/include/flang/Optimizer/HLFIR/HLFIROps.h
@@ -13,6 +13,7 @@
 #include "flang/Optimizer/Dialect/FIRType.h"
 #include "flang/Optimizer/Dialect/FortranVariableInterface.h"
 #include "flang/Optimizer/HLFIR/HLFIRDialect.h"
+#include "mlir/Interfaces/InferTypeOpInterface.h"
 #include "mlir/Interfaces/SideEffectInterfaces.h"
 
 #define GET_OP_CLASSES


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D139520.480874.patch
Type: text/x-patch
Size: 2367 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20221207/b2a74f72/attachment-0001.bin>


More information about the flang-commits mailing list