File tree 2 files changed +16
-1
lines changed 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -572,6 +572,8 @@ OpFoldResult CstrRequireOp::fold(ArrayRef<Attribute> operands) {
572
572
// ===----------------------------------------------------------------------===//
573
573
574
574
OpFoldResult ShapeEqOp::fold (ArrayRef<Attribute> operands) {
575
+ if (lhs () == rhs ())
576
+ return BoolAttr::get (true , getContext ());
575
577
auto lhs = operands[0 ].dyn_cast_or_null <DenseIntElementsAttr>();
576
578
if (lhs == nullptr )
577
579
return {};
Original file line number Diff line number Diff line change @@ -787,7 +787,7 @@ func @shape_eq_fold_0() -> i1 {
787
787
788
788
// -----
789
789
790
- // Do not fold `shape_eq` for non-constant shapes.
790
+ // Do not fold `shape_eq` for non-constant different shapes.
791
791
// CHECK-LABEL: @shape_eq_do_not_fold
792
792
// CHECK-SAME: (%[[A:.*]]: !shape.shape) -> i1
793
793
func @shape_eq_do_not_fold (%a : !shape.shape ) -> i1 {
@@ -799,6 +799,19 @@ func @shape_eq_do_not_fold(%a : !shape.shape) -> i1 {
799
799
return %result : i1
800
800
}
801
801
802
+
803
+ // -----
804
+
805
+ // Fold `shape_eq` for non-constant but same shapes.
806
+ // CHECK-LABEL: @shape_eq_do_fold
807
+ // CHECK-SAME: (%[[A:.*]]: !shape.shape) -> i1
808
+ func @shape_eq_do_fold (%a : !shape.shape ) -> i1 {
809
+ // CHECK: %[[RESULT:.*]] = constant true
810
+ // CHECK: return %[[RESULT]] : i1
811
+ %result = shape.shape_eq %a , %a : !shape.shape , !shape.shape
812
+ return %result : i1
813
+ }
814
+
802
815
// -----
803
816
804
817
// Fold `mul` for constant sizes.
You can’t perform that action at this time.
0 commit comments