[llvm] 28ee604 - [WebAssembly] pmin/pmax fixes

Samuel Parker via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 22 02:02:38 PST 2023


Author: Samuel Parker
Date: 2023-02-22T10:02:16Z
New Revision: 28ee6040710fff44ae1349eadabd4cb4a9b1b1b8

URL: https://github.com/llvm/llvm-project/commit/28ee6040710fff44ae1349eadabd4cb4a9b1b1b8
DIFF: https://github.com/llvm/llvm-project/commit/28ee6040710fff44ae1349eadabd4cb4a9b1b1b8.diff

LOG: [WebAssembly] pmin/pmax fixes

Reverse the operand ordering to ? rhs : lhs.

Differential Revision: https://reviews.llvm.org/D144466

Added: 
    

Modified: 
    llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
    llvm/test/CodeGen/WebAssembly/simd-arith.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td b/llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
index 7f3bcaafd6ea1..e8cea6c0f74a3 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
@@ -1173,19 +1173,19 @@ defm MAX : SIMDBinaryFP<fmaximum, "max", 233>;
 
 // Pseudo-minimum: pmin
 def pmin : PatFrags<(ops node:$lhs, node:$rhs), [
-                    (vselect (setolt $lhs, $rhs), $lhs, $rhs),
-                    (vselect (setole $lhs, $rhs), $lhs, $rhs),
-                    (vselect (setogt $rhs, $lhs), $lhs, $rhs),
-                    (vselect (setoge $rhs, $lhs), $lhs, $rhs)
+                    (vselect (setolt $rhs, $lhs), $rhs, $lhs),
+                    (vselect (setole $rhs, $lhs), $rhs, $lhs),
+                    (vselect (setogt $lhs, $rhs), $rhs, $lhs),
+                    (vselect (setoge $lhs, $rhs), $rhs, $lhs)
 ]>;
 defm PMIN : SIMDBinaryFP<pmin, "pmin", 234>;
 
 // Pseudo-maximum: pmax
 def pmax : PatFrags<(ops node:$lhs, node:$rhs), [
-                    (vselect (setogt $lhs, $rhs), $lhs, $rhs),
-                    (vselect (setoge $lhs, $rhs), $lhs, $rhs),
-                    (vselect (setolt $rhs, $lhs), $lhs, $rhs),
-                    (vselect (setole $rhs, $lhs), $lhs, $rhs)
+                    (vselect (setogt $rhs, $lhs), $rhs, $lhs),
+                    (vselect (setoge $rhs, $lhs), $rhs, $lhs),
+                    (vselect (setolt $lhs, $rhs), $rhs, $lhs),
+                    (vselect (setole $lhs, $rhs), $rhs, $lhs)
 ]>;
 defm PMAX : SIMDBinaryFP<pmax, "pmax", 235>;
 

diff  --git a/llvm/test/CodeGen/WebAssembly/simd-arith.ll b/llvm/test/CodeGen/WebAssembly/simd-arith.ll
index 5ec4d3e6eedab..3a806b955f853 100644
--- a/llvm/test/CodeGen/WebAssembly/simd-arith.ll
+++ b/llvm/test/CodeGen/WebAssembly/simd-arith.ll
@@ -13143,14 +13143,14 @@ define <4 x float> @min_unordered_v4f32(<4 x float> %x) {
 ; SIMD128:         .functype min_unordered_v4f32 (v128) -> (v128)
 ; SIMD128-NEXT:  # %bb.0:
 ; SIMD128-NEXT:    v128.const $push0=, 0x1.4p2, 0x1.4p2, 0x1.4p2, 0x1.4p2
-; SIMD128-NEXT:    f32x4.pmin $push1=, $pop0, $0
+; SIMD128-NEXT:    f32x4.pmin $push1=, $0, $pop0
 ; SIMD128-NEXT:    return $pop1
 ;
 ; SIMD128-FAST-LABEL: min_unordered_v4f32:
 ; SIMD128-FAST:         .functype min_unordered_v4f32 (v128) -> (v128)
 ; SIMD128-FAST-NEXT:  # %bb.0:
 ; SIMD128-FAST-NEXT:    v128.const $push1=, 0x1.4p2, 0x1.4p2, 0x1.4p2, 0x1.4p2
-; SIMD128-FAST-NEXT:    f32x4.pmin $push0=, $pop1, $0
+; SIMD128-FAST-NEXT:    f32x4.pmin $push0=, $0, $pop1
 ; SIMD128-FAST-NEXT:    return $pop0
 ;
 ; NO-SIMD128-LABEL: min_unordered_v4f32:
@@ -13217,14 +13217,14 @@ define <4 x float> @max_unordered_v4f32(<4 x float> %x) {
 ; SIMD128:         .functype max_unordered_v4f32 (v128) -> (v128)
 ; SIMD128-NEXT:  # %bb.0:
 ; SIMD128-NEXT:    v128.const $push0=, 0x1.4p2, 0x1.4p2, 0x1.4p2, 0x1.4p2
-; SIMD128-NEXT:    f32x4.pmax $push1=, $pop0, $0
+; SIMD128-NEXT:    f32x4.pmax $push1=, $0, $pop0
 ; SIMD128-NEXT:    return $pop1
 ;
 ; SIMD128-FAST-LABEL: max_unordered_v4f32:
 ; SIMD128-FAST:         .functype max_unordered_v4f32 (v128) -> (v128)
 ; SIMD128-FAST-NEXT:  # %bb.0:
 ; SIMD128-FAST-NEXT:    v128.const $push1=, 0x1.4p2, 0x1.4p2, 0x1.4p2, 0x1.4p2
-; SIMD128-FAST-NEXT:    f32x4.pmax $push0=, $pop1, $0
+; SIMD128-FAST-NEXT:    f32x4.pmax $push0=, $0, $pop1
 ; SIMD128-FAST-NEXT:    return $pop0
 ;
 ; NO-SIMD128-LABEL: max_unordered_v4f32:
@@ -13291,14 +13291,14 @@ define <4 x float> @min_ordered_v4f32(<4 x float> %x) {
 ; SIMD128:         .functype min_ordered_v4f32 (v128) -> (v128)
 ; SIMD128-NEXT:  # %bb.0:
 ; SIMD128-NEXT:    v128.const $push0=, 0x1.4p2, 0x1.4p2, 0x1.4p2, 0x1.4p2
-; SIMD128-NEXT:    f32x4.pmin $push1=, $pop0, $0
+; SIMD128-NEXT:    f32x4.pmin $push1=, $0, $pop0
 ; SIMD128-NEXT:    return $pop1
 ;
 ; SIMD128-FAST-LABEL: min_ordered_v4f32:
 ; SIMD128-FAST:         .functype min_ordered_v4f32 (v128) -> (v128)
 ; SIMD128-FAST-NEXT:  # %bb.0:
 ; SIMD128-FAST-NEXT:    v128.const $push1=, 0x1.4p2, 0x1.4p2, 0x1.4p2, 0x1.4p2
-; SIMD128-FAST-NEXT:    f32x4.pmin $push0=, $pop1, $0
+; SIMD128-FAST-NEXT:    f32x4.pmin $push0=, $0, $pop1
 ; SIMD128-FAST-NEXT:    return $pop0
 ;
 ; NO-SIMD128-LABEL: min_ordered_v4f32:
@@ -13365,14 +13365,14 @@ define <4 x float> @max_ordered_v4f32(<4 x float> %x) {
 ; SIMD128:         .functype max_ordered_v4f32 (v128) -> (v128)
 ; SIMD128-NEXT:  # %bb.0:
 ; SIMD128-NEXT:    v128.const $push0=, 0x1.4p2, 0x1.4p2, 0x1.4p2, 0x1.4p2
-; SIMD128-NEXT:    f32x4.pmax $push1=, $pop0, $0
+; SIMD128-NEXT:    f32x4.pmax $push1=, $0, $pop0
 ; SIMD128-NEXT:    return $pop1
 ;
 ; SIMD128-FAST-LABEL: max_ordered_v4f32:
 ; SIMD128-FAST:         .functype max_ordered_v4f32 (v128) -> (v128)
 ; SIMD128-FAST-NEXT:  # %bb.0:
 ; SIMD128-FAST-NEXT:    v128.const $push1=, 0x1.4p2, 0x1.4p2, 0x1.4p2, 0x1.4p2
-; SIMD128-FAST-NEXT:    f32x4.pmax $push0=, $pop1, $0
+; SIMD128-FAST-NEXT:    f32x4.pmax $push0=, $0, $pop1
 ; SIMD128-FAST-NEXT:    return $pop0
 ;
 ; NO-SIMD128-LABEL: max_ordered_v4f32:
@@ -14228,13 +14228,13 @@ define <4 x float> @pmin_v4f32(<4 x float> %x, <4 x float> %y) {
 ; SIMD128-LABEL: pmin_v4f32:
 ; SIMD128:         .functype pmin_v4f32 (v128, v128) -> (v128)
 ; SIMD128-NEXT:  # %bb.0:
-; SIMD128-NEXT:    f32x4.pmin $push0=, $1, $0
+; SIMD128-NEXT:    f32x4.pmin $push0=, $0, $1
 ; SIMD128-NEXT:    return $pop0
 ;
 ; SIMD128-FAST-LABEL: pmin_v4f32:
 ; SIMD128-FAST:         .functype pmin_v4f32 (v128, v128) -> (v128)
 ; SIMD128-FAST-NEXT:  # %bb.0:
-; SIMD128-FAST-NEXT:    f32x4.pmin $push0=, $1, $0
+; SIMD128-FAST-NEXT:    f32x4.pmin $push0=, $0, $1
 ; SIMD128-FAST-NEXT:    return $pop0
 ;
 ; NO-SIMD128-LABEL: pmin_v4f32:
@@ -14356,13 +14356,13 @@ define <4 x float> @pmax_v4f32(<4 x float> %x, <4 x float> %y) {
 ; SIMD128-LABEL: pmax_v4f32:
 ; SIMD128:         .functype pmax_v4f32 (v128, v128) -> (v128)
 ; SIMD128-NEXT:  # %bb.0:
-; SIMD128-NEXT:    f32x4.pmax $push0=, $1, $0
+; SIMD128-NEXT:    f32x4.pmax $push0=, $0, $1
 ; SIMD128-NEXT:    return $pop0
 ;
 ; SIMD128-FAST-LABEL: pmax_v4f32:
 ; SIMD128-FAST:         .functype pmax_v4f32 (v128, v128) -> (v128)
 ; SIMD128-FAST-NEXT:  # %bb.0:
-; SIMD128-FAST-NEXT:    f32x4.pmax $push0=, $1, $0
+; SIMD128-FAST-NEXT:    f32x4.pmax $push0=, $0, $1
 ; SIMD128-FAST-NEXT:    return $pop0
 ;
 ; NO-SIMD128-LABEL: pmax_v4f32:
@@ -14789,14 +14789,14 @@ define <2 x double> @min_unordered_v2f64(<2 x double> %x) {
 ; SIMD128:         .functype min_unordered_v2f64 (v128) -> (v128)
 ; SIMD128-NEXT:  # %bb.0:
 ; SIMD128-NEXT:    v128.const $push0=, 0x1.4p2, 0x1.4p2
-; SIMD128-NEXT:    f64x2.pmin $push1=, $pop0, $0
+; SIMD128-NEXT:    f64x2.pmin $push1=, $0, $pop0
 ; SIMD128-NEXT:    return $pop1
 ;
 ; SIMD128-FAST-LABEL: min_unordered_v2f64:
 ; SIMD128-FAST:         .functype min_unordered_v2f64 (v128) -> (v128)
 ; SIMD128-FAST-NEXT:  # %bb.0:
 ; SIMD128-FAST-NEXT:    v128.const $push1=, 0x1.4p2, 0x1.4p2
-; SIMD128-FAST-NEXT:    f64x2.pmin $push0=, $pop1, $0
+; SIMD128-FAST-NEXT:    f64x2.pmin $push0=, $0, $pop1
 ; SIMD128-FAST-NEXT:    return $pop0
 ;
 ; NO-SIMD128-LABEL: min_unordered_v2f64:
@@ -14839,14 +14839,14 @@ define <2 x double> @max_unordered_v2f64(<2 x double> %x) {
 ; SIMD128:         .functype max_unordered_v2f64 (v128) -> (v128)
 ; SIMD128-NEXT:  # %bb.0:
 ; SIMD128-NEXT:    v128.const $push0=, 0x1.4p2, 0x1.4p2
-; SIMD128-NEXT:    f64x2.pmax $push1=, $pop0, $0
+; SIMD128-NEXT:    f64x2.pmax $push1=, $0, $pop0
 ; SIMD128-NEXT:    return $pop1
 ;
 ; SIMD128-FAST-LABEL: max_unordered_v2f64:
 ; SIMD128-FAST:         .functype max_unordered_v2f64 (v128) -> (v128)
 ; SIMD128-FAST-NEXT:  # %bb.0:
 ; SIMD128-FAST-NEXT:    v128.const $push1=, 0x1.4p2, 0x1.4p2
-; SIMD128-FAST-NEXT:    f64x2.pmax $push0=, $pop1, $0
+; SIMD128-FAST-NEXT:    f64x2.pmax $push0=, $0, $pop1
 ; SIMD128-FAST-NEXT:    return $pop0
 ;
 ; NO-SIMD128-LABEL: max_unordered_v2f64:
@@ -14889,14 +14889,14 @@ define <2 x double> @min_ordered_v2f64(<2 x double> %x) {
 ; SIMD128:         .functype min_ordered_v2f64 (v128) -> (v128)
 ; SIMD128-NEXT:  # %bb.0:
 ; SIMD128-NEXT:    v128.const $push0=, 0x1.4p2, 0x1.4p2
-; SIMD128-NEXT:    f64x2.pmin $push1=, $pop0, $0
+; SIMD128-NEXT:    f64x2.pmin $push1=, $0, $pop0
 ; SIMD128-NEXT:    return $pop1
 ;
 ; SIMD128-FAST-LABEL: min_ordered_v2f64:
 ; SIMD128-FAST:         .functype min_ordered_v2f64 (v128) -> (v128)
 ; SIMD128-FAST-NEXT:  # %bb.0:
 ; SIMD128-FAST-NEXT:    v128.const $push1=, 0x1.4p2, 0x1.4p2
-; SIMD128-FAST-NEXT:    f64x2.pmin $push0=, $pop1, $0
+; SIMD128-FAST-NEXT:    f64x2.pmin $push0=, $0, $pop1
 ; SIMD128-FAST-NEXT:    return $pop0
 ;
 ; NO-SIMD128-LABEL: min_ordered_v2f64:
@@ -14939,14 +14939,14 @@ define <2 x double> @max_ordered_v2f64(<2 x double> %x) {
 ; SIMD128:         .functype max_ordered_v2f64 (v128) -> (v128)
 ; SIMD128-NEXT:  # %bb.0:
 ; SIMD128-NEXT:    v128.const $push0=, 0x1.4p2, 0x1.4p2
-; SIMD128-NEXT:    f64x2.pmax $push1=, $pop0, $0
+; SIMD128-NEXT:    f64x2.pmax $push1=, $0, $pop0
 ; SIMD128-NEXT:    return $pop1
 ;
 ; SIMD128-FAST-LABEL: max_ordered_v2f64:
 ; SIMD128-FAST:         .functype max_ordered_v2f64 (v128) -> (v128)
 ; SIMD128-FAST-NEXT:  # %bb.0:
 ; SIMD128-FAST-NEXT:    v128.const $push1=, 0x1.4p2, 0x1.4p2
-; SIMD128-FAST-NEXT:    f64x2.pmax $push0=, $pop1, $0
+; SIMD128-FAST-NEXT:    f64x2.pmax $push0=, $0, $pop1
 ; SIMD128-FAST-NEXT:    return $pop0
 ;
 ; NO-SIMD128-LABEL: max_ordered_v2f64:
@@ -15132,13 +15132,13 @@ define <2 x double> @pmin_v2f64(<2 x double> %x, <2 x double> %y) {
 ; SIMD128-LABEL: pmin_v2f64:
 ; SIMD128:         .functype pmin_v2f64 (v128, v128) -> (v128)
 ; SIMD128-NEXT:  # %bb.0:
-; SIMD128-NEXT:    f64x2.pmin $push0=, $1, $0
+; SIMD128-NEXT:    f64x2.pmin $push0=, $0, $1
 ; SIMD128-NEXT:    return $pop0
 ;
 ; SIMD128-FAST-LABEL: pmin_v2f64:
 ; SIMD128-FAST:         .functype pmin_v2f64 (v128, v128) -> (v128)
 ; SIMD128-FAST-NEXT:  # %bb.0:
-; SIMD128-FAST-NEXT:    f64x2.pmin $push0=, $1, $0
+; SIMD128-FAST-NEXT:    f64x2.pmin $push0=, $0, $1
 ; SIMD128-FAST-NEXT:    return $pop0
 ;
 ; NO-SIMD128-LABEL: pmin_v2f64:
@@ -15220,13 +15220,13 @@ define <2 x double> @pmax_v2f64(<2 x double> %x, <2 x double> %y) {
 ; SIMD128-LABEL: pmax_v2f64:
 ; SIMD128:         .functype pmax_v2f64 (v128, v128) -> (v128)
 ; SIMD128-NEXT:  # %bb.0:
-; SIMD128-NEXT:    f64x2.pmax $push0=, $1, $0
+; SIMD128-NEXT:    f64x2.pmax $push0=, $0, $1
 ; SIMD128-NEXT:    return $pop0
 ;
 ; SIMD128-FAST-LABEL: pmax_v2f64:
 ; SIMD128-FAST:         .functype pmax_v2f64 (v128, v128) -> (v128)
 ; SIMD128-FAST-NEXT:  # %bb.0:
-; SIMD128-FAST-NEXT:    f64x2.pmax $push0=, $1, $0
+; SIMD128-FAST-NEXT:    f64x2.pmax $push0=, $0, $1
 ; SIMD128-FAST-NEXT:    return $pop0
 ;
 ; NO-SIMD128-LABEL: pmax_v2f64:


        


More information about the llvm-commits mailing list