diff --git a/tests/filecheck/transforms/cse.mlir b/tests/filecheck/transforms/cse.mlir index 60a4d0fc6f..68da590f19 100644 --- a/tests/filecheck/transforms/cse.mlir +++ b/tests/filecheck/transforms/cse.mlir @@ -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 diff --git a/xdsl/dialects/builtin.py b/xdsl/dialects/builtin.py index 5ef3fd8b35..820a411b0f 100644 --- a/xdsl/dialects/builtin.py +++ b/xdsl/dialects/builtin.py @@ -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 hash(self.data) + _FloatAttrType = TypeVar("_FloatAttrType", bound=AnyFloat, covariant=True)