This is an archive of the discontinued LLVM Phabricator instance.

Add index::CmpOp canonicalization.
ClosedPublic

Authored by weiweichen on Aug 14 2023, 10:22 AM.

Details

Summary

Add canonicalization pattern for index::CmpOp

Diff Detail

Event Timeline

weiweichen created this revision.Aug 14 2023, 10:22 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 14 2023, 10:22 AM
weiweichen requested review of this revision.Aug 14 2023, 10:22 AM
bzcheeseman added inline comments.Aug 14 2023, 10:32 AM
mlir/lib/Dialect/Index/IR/IndexOps.cpp
569

plz remove else after return

582

Could you make this failure reason a little clearer? I'm not sure what this means.

Also - is there a way to check this up at the top and exit early? It'd reduce the indentation of most of the meat of this function.

Mogball added inline comments.
mlir/include/mlir/Dialect/Index/IR/IndexOps.h
17

Please move this include to the source file

mlir/include/mlir/Dialect/Index/IR/IndexOps.td
544–546
mlir/lib/Dialect/Index/IR/IndexOps.cpp
549–584
559

Please drop all the mlir:: prefixes

569
582
weiweichen added inline comments.Aug 14 2023, 10:49 AM
mlir/include/mlir/Dialect/Index/IR/IndexOps.h
17

Running into error that's from the declaration of the canonicalize function in generated header file, need to add the include into all source files including IndexOps.h and there seem to be ordering related with ordering. Would just include in IndexOps.h a bit easier here?

In file included from /Users/weiwei.chen/research/modularml/modular/third-party/llvm-project/mlir/lib/Dialect/Index/IR/InferIntRangeInterfaceImpls.cpp:9:
In file included from /Users/weiwei.chen/research/modularml/modular/third-party/llvm-project/mlir/include/mlir/Dialect/Index/IR/IndexOps.h:36:
/Users/weiwei.chen/research/modularml/modular/.derived/third-party/cmake-debug-build-llvm/tools/mlir/include/mlir/Dialect/Index/IR/IndexOps.h.inc:1115:63: error: no type named 'PatternRewriter' in namespace 'mlir'
  static ::mlir::LogicalResult canonicalize(CmpOp op, ::mlir::PatternRewriter &rewriter);
Mogball added inline comments.Aug 14 2023, 10:50 AM
mlir/include/mlir/Dialect/Index/IR/IndexOps.h
17

Please add a forward declaration for it

  • Address some review comments.
mlir/include/mlir/Dialect/Index/IR/IndexOps.td
544–546

done

mlir/lib/Dialect/Index/IR/IndexOps.cpp
549–584

done

569

done

582

yes, did a bunch of code reorganizing to reflect the suggestions here

Add forward declaration.

mlir/include/mlir/Dialect/Index/IR/IndexOps.h
17

ah, yes!!

Mogball accepted this revision.Aug 14 2023, 1:14 PM
Mogball added inline comments.
mlir/include/mlir/Dialect/Index/IR/IndexOps.h
26–33
This revision is now accepted and ready to land.Aug 14 2023, 1:14 PM
  • remove empty lines.
This revision was automatically updated to reflect the committed changes.