Move passes implementation to GlobalOptimization. (#15206)

These passes are not related to any flow specific logics, and they are
only used by GlobalOptimization. So we move them to GlobalOptimization/.
The passes are:

- Convert1X1FilterConv2DToMatmul
- DetachElementwiseFromNamedOps
- EraseUnusedLinalgOperands
- RemoveZeroExtentTensors
- SetEncoding
diff --git a/compiler/src/iree/compiler/Dialect/Flow/Transforms/BUILD.bazel b/compiler/src/iree/compiler/Dialect/Flow/Transforms/BUILD.bazel
index 1fbf965..5c9f3ce 100644
--- a/compiler/src/iree/compiler/Dialect/Flow/Transforms/BUILD.bazel
+++ b/compiler/src/iree/compiler/Dialect/Flow/Transforms/BUILD.bazel
@@ -37,14 +37,11 @@
         "CloneProducersIntoDispatchRegions.cpp",
         "CollapseDimensions.cpp",
         "CollapseReductionDims.cpp",
-        "Convert1X1FilterConv2DToMatmul.cpp",
         "ConvertRegionToWorkgroups.cpp",
         "ConvertToFlow.cpp",
         "DeduplicateExecutables.cpp",
-        "DetachElementwiseFromNamedOps.cpp",
         "DispatchWithTransformDialect.cpp",
         "DumpDispatchGraph.cpp",
-        "EraseUnusedLinalgOperands.cpp",
         "ExpandTensorShapes.cpp",
         "ExportBenchmarkFuncs.cpp",
         "FoldUnitExtentDims.cpp",
@@ -66,8 +63,6 @@
         "Passes.cpp",
         "RaiseSpecialOps.cpp",
         "RegionOpUtils.cpp",
-        "RemoveZeroExtentTensors.cpp",
-        "SetEncoding.cpp",
         "SplitReduction.cpp",
         "StripSignedness.cpp",
         "TensorPadToTensorInsertSlice.cpp",
diff --git a/compiler/src/iree/compiler/Dialect/Flow/Transforms/CMakeLists.txt b/compiler/src/iree/compiler/Dialect/Flow/Transforms/CMakeLists.txt
index 3d93121..9c4a07f 100644
--- a/compiler/src/iree/compiler/Dialect/Flow/Transforms/CMakeLists.txt
+++ b/compiler/src/iree/compiler/Dialect/Flow/Transforms/CMakeLists.txt
@@ -36,14 +36,11 @@
     "CloneProducersIntoDispatchRegions.cpp"
     "CollapseDimensions.cpp"
     "CollapseReductionDims.cpp"
-    "Convert1X1FilterConv2DToMatmul.cpp"
     "ConvertRegionToWorkgroups.cpp"
     "ConvertToFlow.cpp"
     "DeduplicateExecutables.cpp"
-    "DetachElementwiseFromNamedOps.cpp"
     "DispatchWithTransformDialect.cpp"
     "DumpDispatchGraph.cpp"
-    "EraseUnusedLinalgOperands.cpp"
     "ExpandTensorShapes.cpp"
     "ExportBenchmarkFuncs.cpp"
     "FoldUnitExtentDims.cpp"
@@ -65,8 +62,6 @@
     "Passes.cpp"
     "RaiseSpecialOps.cpp"
     "RegionOpUtils.cpp"
-    "RemoveZeroExtentTensors.cpp"
-    "SetEncoding.cpp"
     "SplitReduction.cpp"
     "StripSignedness.cpp"
     "TensorPadToTensorInsertSlice.cpp"
diff --git a/compiler/src/iree/compiler/Dialect/Flow/Transforms/Passes.h b/compiler/src/iree/compiler/Dialect/Flow/Transforms/Passes.h
index bbfc494..78dd11a 100644
--- a/compiler/src/iree/compiler/Dialect/Flow/Transforms/Passes.h
+++ b/compiler/src/iree/compiler/Dialect/Flow/Transforms/Passes.h
@@ -49,11 +49,6 @@
 // Input canonicalization and legalization
 //===----------------------------------------------------------------------===//
 
-// Apply patterns to erase unused linalg operands and remove dead code
-// associated.
-std::unique_ptr<OperationPass<mlir::ModuleOp>>
-createEraseUnusedLinalgOperands();
-
 // Expands tensor shape dimensions into SSA values across the program.
 std::unique_ptr<OperationPass<mlir::ModuleOp>> createExpandTensorShapesPass();
 
@@ -64,10 +59,6 @@
 // iree-flow-infer-numeric-narrowing.
 std::unique_ptr<Pass> createCleanupNumericNarrowingPass();
 
-// Creates a pass to convert linalg convolution ops with 1x1 kernels into
-// linalg.matmul
-std::unique_ptr<Pass> createConvert1X1FilterConv2DToMatmulPass();
-
 // Creates a pass to convert dispatch.region ops to dispatch.workgroups ops.
 std::unique_ptr<Pass> createConvertRegionToWorkgroupsPass();
 
@@ -76,9 +67,6 @@
 std::unique_ptr<Pass>
 createTensorPadToTensorInsertSlicePass(bool skipSingleLinalgOpUses = false);
 
-// Create a pass to detach elementwise ops from named Linalg ops.
-std::unique_ptr<Pass> createDetachElementwiseFromNamedOpsPass();
-
 // Create a pass that imports upstream patterns to fold unit extent dims
 // but with IREE control.
 std::unique_ptr<InterfacePass<mlir::FunctionOpInterface>>
@@ -119,17 +107,10 @@
 // iree-flow-infer-numeric-narrowing.
 std::unique_ptr<Pass> createOptimizeNumericsPass();
 
-// Sets encoding for tensors to allow tiled execution of operations.
-std::unique_ptr<Pass> createSetEncodingPass();
-
 // Strips the signed/unsigned portion off of tensors.
 std::unique_ptr<InterfacePass<mlir::FunctionOpInterface>>
 createStripSignednessPass();
 
-// Removes tensors that have 0-extents.
-std::unique_ptr<InterfacePass<mlir::FunctionOpInterface>>
-createRemoveZeroExtentTensorsPass();
-
 // Decomposes top-level SCF operations to CFG.
 std::unique_ptr<InterfacePass<mlir::FunctionOpInterface>>
 createTopLevelSCFToCFGPass();
diff --git a/compiler/src/iree/compiler/Dialect/Flow/Transforms/Passes.td b/compiler/src/iree/compiler/Dialect/Flow/Transforms/Passes.td
index 1b3edf4..5ee617c 100644
--- a/compiler/src/iree/compiler/Dialect/Flow/Transforms/Passes.td
+++ b/compiler/src/iree/compiler/Dialect/Flow/Transforms/Passes.td
@@ -45,12 +45,6 @@
   let constructor = "mlir::iree_compiler::IREE::Flow::createCollapseDimsPass()";
 }
 
-def Convert1X1FilterConv2DToMatmul:
-    Pass<"iree-flow-convert-1x1-filter-conv2d-to-matmul", ""> {
-  let summary = "Convert linalg convolution ops with 1x1 kernels into linalg matrix multiplication ops.";
-  let constructor = "mlir::iree_compiler::IREE::Flow::createConvert1X1FilterConv2DToMatmulPass()";
-}
-
 def ConvertRegionToWorkgroups :
     Pass<"iree-flow-convert-region-to-workgroups", ""> {
   let summary = "Convert DispatchRegion ops to Workgroups ops.";
@@ -69,12 +63,6 @@
   let constructor = "mlir::iree_compiler::IREE::Flow::createDeduplicateExecutablesPass()";
 }
 
-def DetachElementwiseFromNamedOps :
-    Pass<"iree-flow-detach-elementwise-from-named-ops", ""> {
-  let summary = "Detaches elementwise ops from named Linalg ops";
-  let constructor = "mlir::iree_compiler::IREE::Flow::createDetachElementwiseFromNamedOpsPass()";
-}
-
 def FoldUnitExtentDims :
     InterfacePass<"iree-flow-fold-unit-extent-dims", "mlir::FunctionOpInterface"> {
   let summary = "Fold unit extent dimension of operations";
@@ -179,12 +167,6 @@
   let constructor = "mlir::iree_compiler::IREE::Flow::createDumpDispatchGraphPass()";
 }
 
-def EraseUnusedLinalgOperands :
-    Pass<"iree-flow-erase-unused-linalg-operands", "mlir::ModuleOp"> {
-  let summary = "Erase unused linalg operand and remove dead code.";
-  let constructor = "mlir::iree_compiler::IREE::Flow::createEraseUnusedLinalgOperands()";
-}
-
 def ExpandTensorShapes :
     Pass<"iree-flow-expand-tensor-shapes", "mlir::ModuleOp"> {
   let summary = "Expands tensor shape dimensions into SSA values across the program.";
@@ -295,17 +277,6 @@
   let constructor = "mlir::iree_compiler::IREE::Flow::createRaiseSpecialOps()";
 }
 
-def RemoveZeroExtentTensors :
-    InterfacePass<"iree-flow-remove-zero-extent-tensors", "mlir::FunctionOpInterface"> {
-  let summary = "Remove tensors that have 0-extents";
-  let constructor = "mlir::iree_compiler::IREE::Flow::createRemoveZeroExtentTensorsPass()";
-}
-
-def SetEncoding : Pass<"iree-flow-set-encoding", ""> {
-  let summary = "Introduce tensor encoding for compute operations";
-  let constructor = "mlir::iree_compiler::IREE::Flow::createSetEncodingPass()";
-}
-
 def SplitReduction :
     Pass<"iree-flow-split-reduction-ops", ""> {
   let summary = "Split reduction dimension to increase parallelism.";
diff --git a/compiler/src/iree/compiler/Dialect/Flow/Transforms/test/BUILD.bazel b/compiler/src/iree/compiler/Dialect/Flow/Transforms/test/BUILD.bazel
index 3ebe0a8..ef00e97 100644
--- a/compiler/src/iree/compiler/Dialect/Flow/Transforms/test/BUILD.bazel
+++ b/compiler/src/iree/compiler/Dialect/Flow/Transforms/test/BUILD.bazel
@@ -22,10 +22,8 @@
             "cleanup_tensor_shapes.mlir",
             "clone_producers_into_dispatch_regions.mlir",
             "collapse_reduction.mlir",
-            "conv1x1_to_matmul.mlir",
             "convert_region_to_workgroups.mlir",
             "deduplicate_executables.mlir",
-            "detach_elementwise_from_named_ops.mlir",
             "dispatch_linalg_on_tensors.mlir",
             "collapse_linalg_generic_on_tensors.mlir",
             "dispatch_linalg_on_tensors_default.mlir",
@@ -52,8 +50,6 @@
             "pad_fusion_with_producer.mlir",
             "pipeline_tests.mlir",
             "raise_special_ops.mlir",
-            "remove_zero_extent_tensors.mlir",
-            "set_encoding.mlir",
             "strip_signedness.mlir",
             "tensor_pad_to_tensor_insert_slice.mlir",
             "top_level_scf_to_cfg.mlir",
diff --git a/compiler/src/iree/compiler/Dialect/Flow/Transforms/test/CMakeLists.txt b/compiler/src/iree/compiler/Dialect/Flow/Transforms/test/CMakeLists.txt
index ed4b27a..aa7c055 100644
--- a/compiler/src/iree/compiler/Dialect/Flow/Transforms/test/CMakeLists.txt
+++ b/compiler/src/iree/compiler/Dialect/Flow/Transforms/test/CMakeLists.txt
@@ -21,10 +21,8 @@
     "clone_producers_into_dispatch_regions.mlir"
     "collapse_linalg_generic_on_tensors.mlir"
     "collapse_reduction.mlir"
-    "conv1x1_to_matmul.mlir"
     "convert_region_to_workgroups.mlir"
     "deduplicate_executables.mlir"
-    "detach_elementwise_from_named_ops.mlir"
     "dispatch_linalg_on_tensors.mlir"
     "dispatch_linalg_on_tensors_default.mlir"
     "dispatch_linalg_on_tensors_fusion_with_transpose.mlir"
@@ -50,8 +48,6 @@
     "pad_fusion_with_producer.mlir"
     "pipeline_tests.mlir"
     "raise_special_ops.mlir"
-    "remove_zero_extent_tensors.mlir"
-    "set_encoding.mlir"
     "strip_signedness.mlir"
     "tensor_pad_to_tensor_insert_slice.mlir"
     "top_level_scf_to_cfg.mlir"
diff --git a/compiler/src/iree/compiler/GlobalOptimization/BUILD.bazel b/compiler/src/iree/compiler/GlobalOptimization/BUILD.bazel
index e751347..85e819e 100644
--- a/compiler/src/iree/compiler/GlobalOptimization/BUILD.bazel
+++ b/compiler/src/iree/compiler/GlobalOptimization/BUILD.bazel
@@ -44,8 +44,13 @@
 iree_compiler_cc_library(
     name = "GlobalOptimization",
     srcs = [
+        "Convert1X1FilterConv2DToMatmul.cpp",
+        "DetachElementwiseFromNamedOps.cpp",
+        "EraseUnusedLinalgOperands.cpp",
         "MaterializeHomogeneousEncodings.cpp",
         "Passes.cpp",
+        "RemoveZeroExtentTensors.cpp",
+        "SetEncoding.cpp",
     ],
     hdrs = [
         "Passes.h",
@@ -60,12 +65,26 @@
         "//compiler/src/iree/compiler/Dialect/Util/Transforms",
         "//compiler/src/iree/compiler/Pipelines:Options",
         "//compiler/src/iree/compiler/Utils",
+        "//llvm-external-projects/iree-dialects:IREELinalgExtDialect",
+        "//llvm-external-projects/iree-dialects:IREELinalgExtTransforms",
+        "//llvm-external-projects/iree-dialects:IREELinalgExtUtils",
         "@llvm-project//llvm:Support",
+        "@llvm-project//mlir:AffineDialect",
+        "@llvm-project//mlir:ArithDialect",
+        "@llvm-project//mlir:ArithUtils",
+        "@llvm-project//mlir:DialectUtils",
         "@llvm-project//mlir:FuncDialect",
+        "@llvm-project//mlir:FunctionInterfaces",
         "@llvm-project//mlir:IR",
+        "@llvm-project//mlir:LinalgDialect",
         "@llvm-project//mlir:LinalgTransforms",
+        "@llvm-project//mlir:LinalgUtils",
+        "@llvm-project//mlir:MemRefDialect",
         "@llvm-project//mlir:MemRefTransforms",
         "@llvm-project//mlir:Pass",
+        "@llvm-project//mlir:TensorDialect",
+        "@llvm-project//mlir:TensorTransforms",
+        "@llvm-project//mlir:TensorUtils",
         "@llvm-project//mlir:Transforms",
     ],
 )
diff --git a/compiler/src/iree/compiler/GlobalOptimization/CMakeLists.txt b/compiler/src/iree/compiler/GlobalOptimization/CMakeLists.txt
index 7921d38..d534f08 100644
--- a/compiler/src/iree/compiler/GlobalOptimization/CMakeLists.txt
+++ b/compiler/src/iree/compiler/GlobalOptimization/CMakeLists.txt
@@ -39,17 +39,35 @@
   HDRS
     "Passes.h"
   SRCS
+    "Convert1X1FilterConv2DToMatmul.cpp"
+    "DetachElementwiseFromNamedOps.cpp"
+    "EraseUnusedLinalgOperands.cpp"
     "MaterializeHomogeneousEncodings.cpp"
     "Passes.cpp"
+    "RemoveZeroExtentTensors.cpp"
+    "SetEncoding.cpp"
   DEPS
     ::PassHeaders
     ::PassesIncGen
+    IREELinalgExtDialect
+    IREELinalgExtTransforms
+    IREELinalgExtUtils
     LLVMSupport
+    MLIRAffineDialect
+    MLIRArithDialect
+    MLIRArithUtils
     MLIRFuncDialect
+    MLIRFunctionInterfaces
     MLIRIR
+    MLIRLinalgDialect
     MLIRLinalgTransforms
+    MLIRLinalgUtils
+    MLIRMemRefDialect
     MLIRMemRefTransforms
     MLIRPass
+    MLIRTensorDialect
+    MLIRTensorTransforms
+    MLIRTensorUtils
     MLIRTransforms
     iree::compiler::Codegen::Common::CPU::CommonCPUPasses
     iree::compiler::Dialect::Flow::Transforms
diff --git a/compiler/src/iree/compiler/Dialect/Flow/Transforms/Convert1X1FilterConv2DToMatmul.cpp b/compiler/src/iree/compiler/GlobalOptimization/Convert1X1FilterConv2DToMatmul.cpp
similarity index 96%
rename from compiler/src/iree/compiler/Dialect/Flow/Transforms/Convert1X1FilterConv2DToMatmul.cpp
rename to compiler/src/iree/compiler/GlobalOptimization/Convert1X1FilterConv2DToMatmul.cpp
index a2eb556..7b7c912 100644
--- a/compiler/src/iree/compiler/Dialect/Flow/Transforms/Convert1X1FilterConv2DToMatmul.cpp
+++ b/compiler/src/iree/compiler/GlobalOptimization/Convert1X1FilterConv2DToMatmul.cpp
@@ -4,8 +4,8 @@
 // See https://llvm.org/LICENSE.txt for license information.
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 
-#include "iree/compiler/Dialect/Flow/Transforms/PassDetail.h"
-#include "iree/compiler/Dialect/Flow/Transforms/Passes.h"
+#include "iree/compiler/GlobalOptimization/PassDetail.h"
+#include "iree/compiler/GlobalOptimization/Passes.h"
 #include "mlir/Dialect/Linalg/IR/Linalg.h"
 #include "mlir/Dialect/Tensor/IR/Tensor.h"
 #include "mlir/IR/PatternMatch.h"
@@ -14,8 +14,7 @@
 
 namespace mlir {
 namespace iree_compiler {
-namespace IREE {
-namespace Flow {
+namespace GlobalOptimization {
 
 namespace {
 
@@ -184,7 +183,6 @@
   return std::make_unique<Convert1X1FilterConv2DToMatmulPass>();
 }
 
-} // namespace Flow
-} // namespace IREE
+} // namespace GlobalOptimization
 } // namespace iree_compiler
 } // namespace mlir
diff --git a/compiler/src/iree/compiler/Dialect/Flow/Transforms/DetachElementwiseFromNamedOps.cpp b/compiler/src/iree/compiler/GlobalOptimization/DetachElementwiseFromNamedOps.cpp
similarity index 97%
rename from compiler/src/iree/compiler/Dialect/Flow/Transforms/DetachElementwiseFromNamedOps.cpp
rename to compiler/src/iree/compiler/GlobalOptimization/DetachElementwiseFromNamedOps.cpp
index ef4ecab..062cd41 100644
--- a/compiler/src/iree/compiler/Dialect/Flow/Transforms/DetachElementwiseFromNamedOps.cpp
+++ b/compiler/src/iree/compiler/GlobalOptimization/DetachElementwiseFromNamedOps.cpp
@@ -12,8 +12,8 @@
 //===----------------------------------------------------------------------===//
 
 #include "iree-dialects/Dialect/LinalgExt/IR/LinalgExtInterfaces.h"
-#include "iree/compiler/Dialect/Flow/Transforms/PassDetail.h"
-#include "iree/compiler/Dialect/Flow/Transforms/Passes.h"
+#include "iree/compiler/GlobalOptimization/PassDetail.h"
+#include "iree/compiler/GlobalOptimization/Passes.h"
 #include "mlir/Dialect/Arith/IR/Arith.h"
 #include "mlir/Dialect/Linalg/IR/Linalg.h"
 #include "mlir/Dialect/Linalg/IR/LinalgInterfaces.h"
@@ -27,8 +27,7 @@
 
 namespace mlir {
 namespace iree_compiler {
-namespace IREE {
-namespace Flow {
+namespace GlobalOptimization {
 
 namespace {
 
@@ -214,7 +213,6 @@
   return std::make_unique<DetachElementwiseFromNamedOpsPass>();
 }
 
-} // namespace Flow
-} // namespace IREE
+} // namespace GlobalOptimization
 } // namespace iree_compiler
 } // namespace mlir
diff --git a/compiler/src/iree/compiler/Dialect/Flow/Transforms/EraseUnusedLinalgOperands.cpp b/compiler/src/iree/compiler/GlobalOptimization/EraseUnusedLinalgOperands.cpp
similarity index 72%
rename from compiler/src/iree/compiler/Dialect/Flow/Transforms/EraseUnusedLinalgOperands.cpp
rename to compiler/src/iree/compiler/GlobalOptimization/EraseUnusedLinalgOperands.cpp
index 55ad1da..16fa343 100644
--- a/compiler/src/iree/compiler/Dialect/Flow/Transforms/EraseUnusedLinalgOperands.cpp
+++ b/compiler/src/iree/compiler/GlobalOptimization/EraseUnusedLinalgOperands.cpp
@@ -4,22 +4,21 @@
 // See https://llvm.org/LICENSE.txt for license information.
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 
-#include "iree/compiler/Dialect/Flow/Transforms/PassDetail.h"
-#include "iree/compiler/Dialect/Flow/Transforms/Passes.h"
+#include "iree/compiler/GlobalOptimization/PassDetail.h"
+#include "iree/compiler/GlobalOptimization/Passes.h"
 #include "mlir/Dialect/Affine/IR/AffineOps.h"
 #include "mlir/Dialect/Linalg/IR/Linalg.h"
 #include "mlir/Dialect/Linalg/Transforms/Transforms.h"
 #include "mlir/Dialect/MemRef/Transforms/Transforms.h"
 #include "mlir/Transforms/GreedyPatternRewriteDriver.h"
 
-using namespace mlir;
-using namespace mlir::iree_compiler;
-using namespace mlir::iree_compiler::IREE;
+namespace mlir {
+namespace iree_compiler {
+namespace GlobalOptimization {
 
 namespace {
 struct EraseUnusedLinalgOperandsPass
-    : public Flow::EraseUnusedLinalgOperandsBase<
-          EraseUnusedLinalgOperandsPass> {
+    : public EraseUnusedLinalgOperandsBase<EraseUnusedLinalgOperandsPass> {
   void runOnOperation() override {
     MLIRContext *context = &getContext();
     RewritePatternSet patterns(context);
@@ -33,6 +32,10 @@
 } // namespace
 
 std::unique_ptr<OperationPass<mlir::ModuleOp>>
-Flow::createEraseUnusedLinalgOperands() {
+createEraseUnusedLinalgOperands() {
   return std::make_unique<EraseUnusedLinalgOperandsPass>();
 }
+
+} // namespace GlobalOptimization
+} // namespace iree_compiler
+} // namespace mlir
diff --git a/compiler/src/iree/compiler/GlobalOptimization/PassDetail.h b/compiler/src/iree/compiler/GlobalOptimization/PassDetail.h
index d6f91d2..b87a8bd 100644
--- a/compiler/src/iree/compiler/GlobalOptimization/PassDetail.h
+++ b/compiler/src/iree/compiler/GlobalOptimization/PassDetail.h
@@ -8,6 +8,7 @@
 #define IREE_COMPILER_GLOBALOPTIMIZATION_PASSDETAIL_H_
 
 #include "mlir/IR/BuiltinOps.h"
+#include "mlir/Interfaces/FunctionInterfaces.h"
 #include "mlir/Pass/Pass.h"
 
 namespace mlir {
diff --git a/compiler/src/iree/compiler/GlobalOptimization/Passes.cpp b/compiler/src/iree/compiler/GlobalOptimization/Passes.cpp
index 472f7bd..16853dd 100644
--- a/compiler/src/iree/compiler/GlobalOptimization/Passes.cpp
+++ b/compiler/src/iree/compiler/GlobalOptimization/Passes.cpp
@@ -45,11 +45,11 @@
 
   // Preprocessing passes to get the program into a canonical state.
   FunctionLikeNest(mainPassManager)
-      .addPass(IREE::Flow::createRemoveZeroExtentTensorsPass)
-      .addPass(IREE::Flow::createDetachElementwiseFromNamedOpsPass)
+      .addPass(createRemoveZeroExtentTensorsPass)
+      .addPass(createDetachElementwiseFromNamedOpsPass)
       .addPass(mlir::createLinalgNamedOpConversionPass)
-      .addPass(IREE::Flow::createConvert1X1FilterConv2DToMatmulPass);
-  mainPassManager.addPass(IREE::Flow::createEraseUnusedLinalgOperands());
+      .addPass(createConvert1X1FilterConv2DToMatmulPass);
+  mainPassManager.addPass(createEraseUnusedLinalgOperands());
 
   // Expand tensor shapes into SSA values and optimize the whole program.
   // The more we are able to equate shape dimensions at this level the
@@ -70,7 +70,7 @@
       .addPass(IREE::Flow::createFuseDequantizationMatmulPass)
       // Enable data tiling after they are in a canonical form.
       .addPredicatedPass(transformOptions.options.dataTiling,
-                         IREE::Flow::createSetEncodingPass)
+                         createSetEncodingPass)
       .addPass(mlir::createCanonicalizerPass)
       .addPass(mlir::createCSEPass);
   mainPassManager.addPass(createMaterializeHomogeneousEncodingsPass());
diff --git a/compiler/src/iree/compiler/GlobalOptimization/Passes.h b/compiler/src/iree/compiler/GlobalOptimization/Passes.h
index 65552c5..267e308 100644
--- a/compiler/src/iree/compiler/GlobalOptimization/Passes.h
+++ b/compiler/src/iree/compiler/GlobalOptimization/Passes.h
@@ -11,6 +11,7 @@
 
 #include "iree/compiler/Pipelines/Options.h"
 #include "mlir/IR/BuiltinOps.h"
+#include "mlir/Interfaces/FunctionInterfaces.h"
 #include "mlir/Pass/Pass.h"
 #include "mlir/Pass/PassManager.h"
 
@@ -37,11 +38,34 @@
 void buildGlobalOptimizationPassPipeline(
     OpPassManager &mainPassManager, const TransformOptions &transformOptions);
 
+//===----------------------------------------------------------------------===//
+// Input canonicalization and legalization
+//===----------------------------------------------------------------------===//
+
+// Creates a pass to convert linalg convolution ops with 1x1 kernels into
+// linalg.matmul
+std::unique_ptr<Pass> createConvert1X1FilterConv2DToMatmulPass();
+
+// Create a pass to detach elementwise ops from named Linalg ops.
+std::unique_ptr<Pass> createDetachElementwiseFromNamedOpsPass();
+
+// Apply patterns to erase unused linalg operands and remove dead code
+// associated.
+std::unique_ptr<OperationPass<mlir::ModuleOp>>
+createEraseUnusedLinalgOperands();
+
 // Materializes logical encodings to physical encodings if there is a single
 // device target.
 std::unique_ptr<OperationPass<mlir::ModuleOp>>
 createMaterializeHomogeneousEncodingsPass();
 
+// Removes tensors that have 0-extents.
+std::unique_ptr<InterfacePass<mlir::FunctionOpInterface>>
+createRemoveZeroExtentTensorsPass();
+
+// Sets encoding for tensors to allow tiled execution of operations.
+std::unique_ptr<Pass> createSetEncodingPass();
+
 void registerGlobalOptimizationPipeline();
 
 } // namespace GlobalOptimization
diff --git a/compiler/src/iree/compiler/GlobalOptimization/Passes.td b/compiler/src/iree/compiler/GlobalOptimization/Passes.td
index e07e4e8..acba442 100644
--- a/compiler/src/iree/compiler/GlobalOptimization/Passes.td
+++ b/compiler/src/iree/compiler/GlobalOptimization/Passes.td
@@ -9,6 +9,24 @@
 
 include "mlir/Pass/PassBase.td"
 
+def Convert1X1FilterConv2DToMatmul:
+    Pass<"iree-global-opt-convert-1x1-filter-conv2d-to-matmul", ""> {
+  let summary = "Convert linalg convolution ops with 1x1 kernels into linalg matrix multiplication ops.";
+  let constructor = "mlir::iree_compiler::GlobalOptimization::createConvert1X1FilterConv2DToMatmulPass()";
+}
+
+def DetachElementwiseFromNamedOps :
+    Pass<"iree-global-opt-detach-elementwise-from-named-ops", ""> {
+  let summary = "Detaches elementwise ops from named Linalg ops";
+  let constructor = "mlir::iree_compiler::GlobalOptimization::createDetachElementwiseFromNamedOpsPass()";
+}
+
+def EraseUnusedLinalgOperands :
+    Pass<"iree-global-opt-erase-unused-linalg-operands", "mlir::ModuleOp"> {
+  let summary = "Erase unused linalg operand and remove dead code.";
+  let constructor = "mlir::iree_compiler::GlobalOptimization::createEraseUnusedLinalgOperands()";
+}
+
 def MaterializeHomogeneousEncodings :
   Pass<"iree-global-opt-materialize-homogeneous-encodings", "mlir::ModuleOp"> {
   let summary = "Materializes logical encodings to physical encodings if there is a single device target.";
@@ -16,4 +34,15 @@
   "mlir::iree_compiler::GlobalOptimization::createMaterializeHomogeneousEncodingsPass()";
 }
 
+def RemoveZeroExtentTensors :
+    InterfacePass<"iree-global-opt-remove-zero-extent-tensors", "mlir::FunctionOpInterface"> {
+  let summary = "Remove tensors that have 0-extents";
+  let constructor = "mlir::iree_compiler::GlobalOptimization::createRemoveZeroExtentTensorsPass()";
+}
+
+def SetEncoding : Pass<"iree-global-opt-set-encoding", ""> {
+  let summary = "Introduce tensor encoding for compute operations";
+  let constructor = "mlir::iree_compiler::GlobalOptimization::createSetEncodingPass()";
+}
+
 #endif // IREE_COMPILER_GLOBALOPTIMIZATION_PASSES
diff --git a/compiler/src/iree/compiler/Dialect/Flow/Transforms/RemoveZeroExtentTensors.cpp b/compiler/src/iree/compiler/GlobalOptimization/RemoveZeroExtentTensors.cpp
similarity index 94%
rename from compiler/src/iree/compiler/Dialect/Flow/Transforms/RemoveZeroExtentTensors.cpp
rename to compiler/src/iree/compiler/GlobalOptimization/RemoveZeroExtentTensors.cpp
index 1458189..0668854 100644
--- a/compiler/src/iree/compiler/Dialect/Flow/Transforms/RemoveZeroExtentTensors.cpp
+++ b/compiler/src/iree/compiler/GlobalOptimization/RemoveZeroExtentTensors.cpp
@@ -4,17 +4,17 @@
 // See https://llvm.org/LICENSE.txt for license information.
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 
-#include "iree/compiler/Dialect/Flow/Transforms/PassDetail.h"
-#include "iree/compiler/Dialect/Flow/Transforms/Passes.h"
+#include "iree/compiler/GlobalOptimization/PassDetail.h"
+#include "iree/compiler/GlobalOptimization/Passes.h"
 #include "mlir/Dialect/MemRef/Transforms/Transforms.h"
 #include "mlir/Dialect/Tensor/IR/Tensor.h"
+#include "mlir/Interfaces/FunctionInterfaces.h"
 #include "mlir/Pass/Pass.h"
 #include "mlir/Transforms/GreedyPatternRewriteDriver.h"
 
 namespace mlir {
 namespace iree_compiler {
-namespace IREE {
-namespace Flow {
+namespace GlobalOptimization {
 
 /// Check if a `t` is a `tensor` with zero extents.
 static std::optional<RankedTensorType> isZeroExtent(Type t) {
@@ -108,7 +108,6 @@
   return std::make_unique<RemoveZeroExtentTensorsPass>();
 }
 
-} // namespace Flow
-} // namespace IREE
+} // namespace GlobalOptimization
 } // namespace iree_compiler
 } // namespace mlir
diff --git a/compiler/src/iree/compiler/Dialect/Flow/Transforms/SetEncoding.cpp b/compiler/src/iree/compiler/GlobalOptimization/SetEncoding.cpp
similarity index 88%
rename from compiler/src/iree/compiler/Dialect/Flow/Transforms/SetEncoding.cpp
rename to compiler/src/iree/compiler/GlobalOptimization/SetEncoding.cpp
index 76acd4c..6177897 100644
--- a/compiler/src/iree/compiler/Dialect/Flow/Transforms/SetEncoding.cpp
+++ b/compiler/src/iree/compiler/GlobalOptimization/SetEncoding.cpp
@@ -12,8 +12,8 @@
 #include "iree-dialects/Dialect/LinalgExt/IR/LinalgExtDialect.h"
 #include "iree-dialects/Dialect/LinalgExt/IR/LinalgExtOps.h"
 #include "iree-dialects/Dialect/LinalgExt/Utils/Utils.h"
-#include "iree/compiler/Dialect/Flow/Transforms/PassDetail.h"
-#include "iree/compiler/Dialect/Flow/Transforms/Passes.h"
+#include "iree/compiler/GlobalOptimization/PassDetail.h"
+#include "iree/compiler/GlobalOptimization/Passes.h"
 #include "mlir/Dialect/Affine/IR/AffineOps.h"
 #include "mlir/Dialect/Arith/IR/Arith.h"
 #include "mlir/Dialect/Arith/Utils/Utils.h"
@@ -35,8 +35,7 @@
 
 namespace mlir {
 namespace iree_compiler {
-namespace IREE {
-namespace Flow {
+namespace GlobalOptimization {
 
 //===---------------------------------------------------------------------===//
 // Utility functions
@@ -85,14 +84,13 @@
                                                         source);
 };
 
-static LinalgExt::EncodingAttr makeEncoding(OpBuilder &builder,
-                                            LinalgExt::EncodingUser user,
-                                            LinalgExt::EncodingRole role,
-                                            TypeRange operandTypes,
-                                            Type originalType) {
+static IREE::LinalgExt::EncodingAttr
+makeEncoding(OpBuilder &builder, IREE::LinalgExt::EncodingUser user,
+             IREE::LinalgExt::EncodingRole role, TypeRange operandTypes,
+             Type originalType) {
   auto *context = builder.getContext();
-  auto userAttr = LinalgExt::EncodingUserAttr::get(context, user);
-  auto roleAttr = LinalgExt::EncodingRoleAttr::get(context, role);
+  auto userAttr = IREE::LinalgExt::EncodingUserAttr::get(context, user);
+  auto roleAttr = IREE::LinalgExt::EncodingRoleAttr::get(context, role);
   SmallVector<Attribute> elemTypeAttrs =
       llvm::map_to_vector(operandTypes, [](auto t) {
         return TypeAttr::get(t.template cast<ShapedType>().getElementType())
@@ -101,13 +99,13 @@
   auto operandElemTypesAttr = ArrayAttr::get(context, elemTypeAttrs);
   auto originalTypeAttr =
       originalType ? TypeAttr::get(originalType) : TypeAttr{};
-  return LinalgExt::EncodingAttr::get(context, userAttr, roleAttr,
-                                      operandElemTypesAttr, originalTypeAttr);
+  return IREE::LinalgExt::EncodingAttr::get(
+      context, userAttr, roleAttr, operandElemTypesAttr, originalTypeAttr);
 }
 
 static Value padAndSetEncoding(OpBuilder &builder, Location loc, Value source,
-                               LinalgExt::EncodingUser user,
-                               LinalgExt::EncodingRole role,
+                               IREE::LinalgExt::EncodingUser user,
+                               IREE::LinalgExt::EncodingRole role,
                                TypeRange operandTypes) {
   // No need to specify original_type in the encoding poadded to pad(), because
   // the operand there is the `source` tensor, so it will default to reading its
@@ -187,18 +185,18 @@
       return failure();
     }
 
-    LinalgExt::EncodingUser user = LinalgExt::EncodingUser::MATMUL;
+    IREE::LinalgExt::EncodingUser user = IREE::LinalgExt::EncodingUser::MATMUL;
     Location loc = matmulOp.getLoc();
     TypeRange operandTypes = matmulOp->getOperandTypes();
     Value encodedLhs =
         padAndSetEncoding(rewriter, loc, origLhs, user,
-                          LinalgExt::EncodingRole::LHS, operandTypes);
+                          IREE::LinalgExt::EncodingRole::LHS, operandTypes);
     Value encodedRhs =
         padAndSetEncoding(rewriter, loc, origRhs, user,
-                          LinalgExt::EncodingRole::RHS, operandTypes);
+                          IREE::LinalgExt::EncodingRole::RHS, operandTypes);
     Value encodedOut =
         padAndSetEncoding(rewriter, loc, origOut, user,
-                          LinalgExt::EncodingRole::RESULT, operandTypes);
+                          IREE::LinalgExt::EncodingRole::RESULT, operandTypes);
 
     Value matmulTiled = rewriter
                             .create<linalg::MatmulOp>(
@@ -208,7 +206,7 @@
 
     // Sizes are computed by original output size.
     FailureOr<SmallVector<OpFoldResult>> origOutSizes =
-        LinalgExt::getDims(rewriter, loc, origOut);
+        IREE::LinalgExt::getDims(rewriter, loc, origOut);
     if (failed(origOutSizes)) {
       return rewriter.notifyMatchFailure(matmulOp,
                                          "failed to get shape of result");
@@ -259,18 +257,19 @@
       return failure();
     }
 
-    LinalgExt::EncodingUser user = LinalgExt::EncodingUser::BATCH_MATMUL;
+    IREE::LinalgExt::EncodingUser user =
+        IREE::LinalgExt::EncodingUser::BATCH_MATMUL;
     Location loc = matmulOp.getLoc();
     TypeRange operandTypes = matmulOp->getOperandTypes();
     Value encodedLhs =
         padAndSetEncoding(rewriter, loc, origLhs, user,
-                          LinalgExt::EncodingRole::LHS, operandTypes);
+                          IREE::LinalgExt::EncodingRole::LHS, operandTypes);
     Value encodedRhs =
         padAndSetEncoding(rewriter, loc, origRhs, user,
-                          LinalgExt::EncodingRole::RHS, operandTypes);
+                          IREE::LinalgExt::EncodingRole::RHS, operandTypes);
     Value encodedOut =
         padAndSetEncoding(rewriter, loc, origOut, user,
-                          LinalgExt::EncodingRole::RESULT, operandTypes);
+                          IREE::LinalgExt::EncodingRole::RESULT, operandTypes);
 
     Value matmulTiled = rewriter
                             .create<linalg::BatchMatmulOp>(
@@ -280,7 +279,7 @@
 
     // Sizes are computed by original output size.
     FailureOr<SmallVector<OpFoldResult>> origOutSizes =
-        LinalgExt::getDims(rewriter, loc, origOut);
+        IREE::LinalgExt::getDims(rewriter, loc, origOut);
     if (failed(origOutSizes)) {
       return rewriter.notifyMatchFailure(matmulOp,
                                          "failed to get shape of result");
@@ -348,7 +347,6 @@
   return std::make_unique<SetEncodingPass>();
 }
 
-} // namespace Flow
-} // namespace IREE
+} // namespace GlobalOptimization
 } // namespace iree_compiler
 } // namespace mlir
diff --git a/compiler/src/iree/compiler/GlobalOptimization/test/BUILD.bazel b/compiler/src/iree/compiler/GlobalOptimization/test/BUILD.bazel
index 6c04272..8cd9993 100644
--- a/compiler/src/iree/compiler/GlobalOptimization/test/BUILD.bazel
+++ b/compiler/src/iree/compiler/GlobalOptimization/test/BUILD.bazel
@@ -16,8 +16,12 @@
     name = "lit",
     srcs = enforce_glob(
         [
-            "transformation_pipeline.mlir",
+            "conv1x1_to_matmul.mlir",
+            "detach_elementwise_from_named_ops.mlir",
             "materialize_homogeneous_encodings.mlir",
+            "remove_zero_extent_tensors.mlir",
+            "set_encoding.mlir",
+            "transformation_pipeline.mlir",
         ],
         include = ["*.mlir"],
     ),
diff --git a/compiler/src/iree/compiler/GlobalOptimization/test/CMakeLists.txt b/compiler/src/iree/compiler/GlobalOptimization/test/CMakeLists.txt
index 1924cd4..02709fd 100644
--- a/compiler/src/iree/compiler/GlobalOptimization/test/CMakeLists.txt
+++ b/compiler/src/iree/compiler/GlobalOptimization/test/CMakeLists.txt
@@ -14,7 +14,11 @@
   NAME
     lit
   SRCS
+    "conv1x1_to_matmul.mlir"
+    "detach_elementwise_from_named_ops.mlir"
     "materialize_homogeneous_encodings.mlir"
+    "remove_zero_extent_tensors.mlir"
+    "set_encoding.mlir"
     "transformation_pipeline.mlir"
   TOOLS
     FileCheck
diff --git a/compiler/src/iree/compiler/Dialect/Flow/Transforms/test/conv1x1_to_matmul.mlir b/compiler/src/iree/compiler/GlobalOptimization/test/conv1x1_to_matmul.mlir
similarity index 98%
rename from compiler/src/iree/compiler/Dialect/Flow/Transforms/test/conv1x1_to_matmul.mlir
rename to compiler/src/iree/compiler/GlobalOptimization/test/conv1x1_to_matmul.mlir
index f70d9c2..18df3dd 100644
--- a/compiler/src/iree/compiler/Dialect/Flow/Transforms/test/conv1x1_to_matmul.mlir
+++ b/compiler/src/iree/compiler/GlobalOptimization/test/conv1x1_to_matmul.mlir
@@ -1,4 +1,4 @@
-// RUN: iree-opt --split-input-file -iree-flow-convert-1x1-filter-conv2d-to-matmul %s | FileCheck %s
+// RUN: iree-opt --split-input-file -iree-global-opt-convert-1x1-filter-conv2d-to-matmul %s | FileCheck %s
 
 func.func @nhwc_conv_2d(%input: tensor<1x4x5x2xf32>, %filter: tensor<1x1x2x7xf32>) -> tensor<1x4x5x7xf32> {
     %0 = tensor.empty() : tensor<1x4x5x7xf32>
diff --git a/compiler/src/iree/compiler/Dialect/Flow/Transforms/test/detach_elementwise_from_named_ops.mlir b/compiler/src/iree/compiler/GlobalOptimization/test/detach_elementwise_from_named_ops.mlir
similarity index 98%
rename from compiler/src/iree/compiler/Dialect/Flow/Transforms/test/detach_elementwise_from_named_ops.mlir
rename to compiler/src/iree/compiler/GlobalOptimization/test/detach_elementwise_from_named_ops.mlir
index 3b2b972..162acf9 100644
--- a/compiler/src/iree/compiler/Dialect/Flow/Transforms/test/detach_elementwise_from_named_ops.mlir
+++ b/compiler/src/iree/compiler/GlobalOptimization/test/detach_elementwise_from_named_ops.mlir
@@ -1,4 +1,4 @@
-// RUN: iree-opt --split-input-file --iree-flow-detach-elementwise-from-named-ops --mlir-print-local-scope %s | FileCheck %s
+// RUN: iree-opt --split-input-file --iree-global-opt-detach-elementwise-from-named-ops --mlir-print-local-scope %s | FileCheck %s
 
 func.func @matmul(%a: tensor<?x64xf32>, %b: tensor<64x?xf32>, %c: tensor<?x?xf32>) -> tensor<?x?xf32> {
   %0 = linalg.generic {
diff --git a/compiler/src/iree/compiler/Dialect/Flow/Transforms/test/remove_zero_extent_tensors.mlir b/compiler/src/iree/compiler/GlobalOptimization/test/remove_zero_extent_tensors.mlir
similarity index 97%
rename from compiler/src/iree/compiler/Dialect/Flow/Transforms/test/remove_zero_extent_tensors.mlir
rename to compiler/src/iree/compiler/GlobalOptimization/test/remove_zero_extent_tensors.mlir
index 6cf83f4..dffb238 100644
--- a/compiler/src/iree/compiler/Dialect/Flow/Transforms/test/remove_zero_extent_tensors.mlir
+++ b/compiler/src/iree/compiler/GlobalOptimization/test/remove_zero_extent_tensors.mlir
@@ -1,5 +1,5 @@
 // RUN: iree-opt --split-input-file --allow-unregistered-dialect \
-// RUN:          --pass-pipeline="builtin.module(func.func(iree-flow-remove-zero-extent-tensors))" \
+// RUN:          --pass-pipeline="builtin.module(func.func(iree-global-opt-remove-zero-extent-tensors))" \
 // RUN:          %s | FileCheck %s
 
 func.func @zero_sized_operands(%arg0 : tensor<?x0xf32>, %arg1 : index) -> tensor<?x?xf32> {
diff --git a/compiler/src/iree/compiler/Dialect/Flow/Transforms/test/set_encoding.mlir b/compiler/src/iree/compiler/GlobalOptimization/test/set_encoding.mlir
similarity index 99%
rename from compiler/src/iree/compiler/Dialect/Flow/Transforms/test/set_encoding.mlir
rename to compiler/src/iree/compiler/GlobalOptimization/test/set_encoding.mlir
index 85b3fd2..e51ec26 100644
--- a/compiler/src/iree/compiler/Dialect/Flow/Transforms/test/set_encoding.mlir
+++ b/compiler/src/iree/compiler/GlobalOptimization/test/set_encoding.mlir
@@ -1,4 +1,4 @@
-// RUN: iree-opt --iree-flow-set-encoding --cse --split-input-file %s | FileCheck %s
+// RUN: iree-opt --iree-global-opt-set-encoding --cse --split-input-file %s | FileCheck %s
 
 func.func @matmul_f32f32f32(%arg0 : tensor<100x250xf32>, %arg1 : tensor<250x500xf32>,
     %arg2 : tensor<100x500xf32>) -> tensor<100x500xf32> {