forked from OSchip/llvm-project
Mark arith.minf, arith.maxf as commutative.
Reviewed By: herhut Differential Revision: https://reviews.llvm.org/D117010
This commit is contained in:
parent
e838949bee
commit
d345ce65ff
|
@ -634,7 +634,7 @@ def Arith_SubFOp : Arith_FloatBinaryOp<"subf"> {
|
|||
// MaxFOp
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
def Arith_MaxFOp : Arith_FloatBinaryOp<"maxf"> {
|
||||
def Arith_MaxFOp : Arith_FloatBinaryOp<"maxf", [Commutative]> {
|
||||
let summary = "floating-point maximum operation";
|
||||
let description = [{
|
||||
Syntax:
|
||||
|
@ -677,7 +677,7 @@ def Arith_MaxUIOp : Arith_IntBinaryOp<"maxui"> {
|
|||
// MinFOp
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
def Arith_MinFOp : Arith_FloatBinaryOp<"minf"> {
|
||||
def Arith_MinFOp : Arith_FloatBinaryOp<"minf", [Commutative]> {
|
||||
let summary = "floating-point minimum operation";
|
||||
let description = [{
|
||||
Syntax:
|
||||
|
|
|
@ -678,3 +678,16 @@ func @constant_UItoFP() -> f32 {
|
|||
%res = arith.sitofp %c0 : i32 to f32
|
||||
return %res : f32
|
||||
}
|
||||
|
||||
// -----
|
||||
// CHECK-LABEL: @constant_MinMax(
|
||||
func @constant_MinMax(%arg0 : f32) -> f32 {
|
||||
// CHECK: %[[const:.+]] = arith.constant
|
||||
// CHECK: %[[min:.+]] = arith.minf %arg0, %[[const]] : f32
|
||||
// CHECK: %[[res:.+]] = arith.maxf %[[min]], %[[const]] : f32
|
||||
// CHECK: return %[[res]]
|
||||
%const = arith.constant 0.0 : f32
|
||||
%min = arith.minf %const, %arg0 : f32
|
||||
%res = arith.maxf %const, %min : f32
|
||||
return %res : f32
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue