Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: Fix cse for FloatData #3396

Merged
merged 4 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions tests/filecheck/transforms/cse.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@ func.func @simple_constant() -> (i32, i32) {
// CHECK-NEXT: func.return %0, %0 : i32, i32
// CHECK-NEXT: }

func.func @simple_float_constant() -> (f32, f32) {
%0 = arith.constant 1.0 : f32
%1 = arith.constant 1.0 : f32
func.return %0, %1 : f32, f32
}

// CHECK: func.func @simple_float_constant() -> (f32, f32) {
// CHECK-NEXT: %0 = arith.constant 1.000000e+00 : f32
// CHECK-NEXT: func.return %0, %0 : f32, f32
// CHECK-NEXT: }

// CHECK-LABEL: @basic
func.func @basic() -> (index, index) {
%2 = arith.constant 0 : index
Expand Down
3 changes: 3 additions & 0 deletions xdsl/dialects/builtin.py
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,9 @@ def __eq__(self, other: Any):
math.isnan(self.data) and math.isnan(other.data) or self.data == other.data
)

def __hash__(self):
return super().__hash__()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work? Would cut out the middle man

Suggested change
return super().__hash__()
return hash(self.data)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does indeed



_FloatAttrType = TypeVar("_FloatAttrType", bound=AnyFloat, covariant=True)

Expand Down
Loading