https://gcc.gnu.org/g:b3b14d8bec72de46bf0721e367756d13b1b3044f

commit b3b14d8bec72de46bf0721e367756d13b1b3044f
Author: Michael Meissner <meiss...@linux.ibm.com>
Date:   Wed May 21 10:44:41 2025 -0400

    Revert changes

Diff:
---
 gcc/config/rs6000/predicates.md             |  10 +-
 gcc/config/rs6000/rs6000-protos.h           |  17 +---
 gcc/config/rs6000/rs6000.cc                 |  35 ++-----
 gcc/config/rs6000/rs6000.h                  |  13 +--
 gcc/config/rs6000/rs6000.md                 |  25 ++---
 gcc/testsuite/gcc.target/powerpc/pr118541.c | 147 ----------------------------
 6 files changed, 24 insertions(+), 223 deletions(-)

diff --git a/gcc/config/rs6000/predicates.md b/gcc/config/rs6000/predicates.md
index ba8df6a7979d..647e89afb6a7 100644
--- a/gcc/config/rs6000/predicates.md
+++ b/gcc/config/rs6000/predicates.md
@@ -1466,16 +1466,8 @@
 ;; Return 1 if OP is a comparison operator suitable for vector/scalar
 ;; comparisons that generate a 0/-1 mask (i.e. the inverse of
 ;; fpmask_comparison_operator).
-;;
-;; invert_fpmask_comparison_operator is used to form floating point conditional
-;; moves on power9.  The instructions that would be generated (xscmpeqdp,
-;; xscmpgtdp, or xscmpgedp) will raise an error if one of the arguments is a
-;; signalling NaN.  Don't allow the test to be inverted if NaNs are supported
-;; and the comparison is an ordered comparison.
 (define_predicate "invert_fpmask_comparison_operator"
-  (ior (match_code "ne")
-       (and (match_code "unlt,unle")
-           (match_test "flag_finite_math_only"))))
+  (match_code "ne,unlt,unle"))
 
 ;; Return 1 if OP is a comparison operation suitable for integer vector/scalar
 ;; comparisons that generate a -1/0 mask.
diff --git a/gcc/config/rs6000/rs6000-protos.h 
b/gcc/config/rs6000/rs6000-protos.h
index 5beb44fc339b..4619142d197b 100644
--- a/gcc/config/rs6000/rs6000-protos.h
+++ b/gcc/config/rs6000/rs6000-protos.h
@@ -114,23 +114,8 @@ extern const char *rs6000_sibcall_template (rtx *, 
unsigned int);
 extern const char *rs6000_indirect_call_template (rtx *, unsigned int);
 extern const char *rs6000_indirect_sibcall_template (rtx *, unsigned int);
 extern const char *rs6000_pltseq_template (rtx *, int);
-
-/* Whether we can reverse the sense of an ordered (UNLT, UNLE, UNGT, UNGE,
-   UNEQ, or LTGT) comparison.  If we are doing floating point conditional moves
-   on power9 and above, we cannot convert an ordered comparison to unordered,
-   since the instructions (XSCMP{EQ,GT,GE}DP) that are used for conditional
-   moves can trap if an argument is a signalling NaN.  However for normal jumps
-   we can reverse a comparison since we only use unordered compare instructions
-   which do not trap on signalling NaNs.  */
-
-enum class rev_cond_ordered {
-  ordered_ok,
-  no_ordered
-};
-
 extern enum rtx_code rs6000_reverse_condition (machine_mode,
-                                              enum rtx_code,
-                                              enum rev_cond_ordered);
+                                              enum rtx_code);
 extern rtx rs6000_emit_eqne (machine_mode, rtx, rtx, rtx);
 extern rtx rs6000_emit_fp_cror (rtx_code, machine_mode, rtx);
 extern void rs6000_emit_sCOND (machine_mode, rtx[]);
diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc
index 86660fc534ff..11dfde7f288b 100644
--- a/gcc/config/rs6000/rs6000.cc
+++ b/gcc/config/rs6000/rs6000.cc
@@ -9358,8 +9358,7 @@ rs6000_debug_legitimize_address (rtx x, rtx oldx, 
machine_mode mode)
 
   start_sequence ();
   ret = rs6000_legitimize_address (x, oldx, mode);
-  insns = get_insns ();
-  end_sequence ();
+  insns = end_sequence ();
 
   if (ret != x)
     {
@@ -15367,28 +15366,17 @@ rs6000_print_patchable_function_entry (FILE *file,
 }
 
 enum rtx_code
-rs6000_reverse_condition (machine_mode mode,
-                         enum rtx_code code,
-                         enum rev_cond_ordered ordered_cmp_ok)
+rs6000_reverse_condition (machine_mode mode, enum rtx_code code)
 {
   /* Reversal of FP compares takes care -- an ordered compare
-     becomes an unordered compare and vice versa.
-
-     However, this is not safe for ordered comparisons (i.e. for isgreater,
-     etc.)  starting with the power9 because ifcvt.cc will want to create a fp
-     cmove, and the x{s,v}cmp{eq,gt,ge}{dp,qp} instructions will trap if one of
-     the arguments is a signalling NaN.  */
-
+     becomes an unordered compare and vice versa.  */
   if (mode == CCFPmode
-      && (code == UNLT || code == UNLE || code == UNGT || code == UNGE
+      && (!flag_finite_math_only
+         || code == UNLT || code == UNLE || code == UNGT || code == UNGE
          || code == UNEQ || code == LTGT))
-    {
-      return (ordered_cmp_ok == rev_cond_ordered::no_ordered
-             ? UNKNOWN
-             : reverse_condition_maybe_unordered (code));
-    }
-
-  return reverse_condition (code);
+    return reverse_condition_maybe_unordered (code);
+  else
+    return reverse_condition (code);
 }
 
 /* Check if C (as 64bit integer) can be rotated to a constant which constains
@@ -15998,14 +15986,11 @@ rs6000_emit_sCOND (machine_mode mode, rtx operands[])
       rtx not_result = gen_reg_rtx (CCEQmode);
       rtx not_op, rev_cond_rtx;
       machine_mode cc_mode;
-      rtx_code rev;
 
       cc_mode = GET_MODE (XEXP (condition_rtx, 0));
 
-      rev = rs6000_reverse_condition (cc_mode, cond_code,
-                                     rev_cond_ordered::ordered_ok);
-      rev_cond_rtx = gen_rtx_fmt_ee (rev, SImode, XEXP (condition_rtx, 0),
-                                    const0_rtx);
+      rev_cond_rtx = gen_rtx_fmt_ee (rs6000_reverse_condition (cc_mode, 
cond_code),
+                                    SImode, XEXP (condition_rtx, 0), 
const0_rtx);
       not_op = gen_rtx_COMPARE (CCEQmode, rev_cond_rtx, const0_rtx);
       emit_insn (gen_rtx_SET (not_result, not_op));
       condition_rtx = gen_rtx_EQ (VOIDmode, not_result, const0_rtx);
diff --git a/gcc/config/rs6000/rs6000.h b/gcc/config/rs6000/rs6000.h
index d09032b09ace..9267612fbc9c 100644
--- a/gcc/config/rs6000/rs6000.h
+++ b/gcc/config/rs6000/rs6000.h
@@ -1812,18 +1812,11 @@ extern scalar_int_mode rs6000_pmode;
 
 /* Can the condition code MODE be safely reversed?  This is safe in
    all cases on this port, because at present it doesn't use the
-   trapping FP comparisons (fcmpo).
-
-   However, this is not safe for ordered comparisons (i.e. for isgreater, etc.)
-   starting with the power9 because ifcvt.cc will want to create a fp cmove,
-   and the x{s,v}cmp{eq,gt,ge}{dp,qp} instructions will trap if one of the
-   arguments is a signalling NaN.  */
-#define REVERSIBLE_CC_MODE(MODE)                                       \
-  (flag_finite_math_only || !TARGET_P9_VECTOR || (MODE) != CCFPmode)
+   trapping FP comparisons (fcmpo).  */
+#define REVERSIBLE_CC_MODE(MODE) 1
 
 /* Given a condition code and a mode, return the inverse condition.  */
-#define REVERSE_CONDITION(CODE, MODE)                                  \
-  rs6000_reverse_condition (MODE, CODE, rev_cond_ordered::no_ordered)
+#define REVERSE_CONDITION(CODE, MODE) rs6000_reverse_condition (MODE, CODE)
 
 
 /* Target cpu costs.  */
diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md
index 4542540fcf8f..65da0c653304 100644
--- a/gcc/config/rs6000/rs6000.md
+++ b/gcc/config/rs6000/rs6000.md
@@ -13497,7 +13497,7 @@
 ;; If we are comparing the result of two comparisons, this can be done
 ;; using creqv or crxor.
 
-(define_insn_and_split "reverse_branch_comparison"
+(define_insn_and_split ""
   [(set (match_operand:CCEQ 0 "cc_reg_operand" "=y")
        (compare:CCEQ (match_operator 1 "branch_comparison_operator"
                              [(match_operand 2 "cc_reg_operand" "y")
@@ -13512,7 +13512,6 @@
                                    (match_dup 5)))]
 {
   int positive_1, positive_2;
-  enum rev_cond_ordered order_ok = rev_cond_ordered::ordered_ok;
 
   positive_1 = branch_positive_comparison_operator (operands[1],
                                                    GET_MODE (operands[1]));
@@ -13520,25 +13519,19 @@
                                                    GET_MODE (operands[3]));
 
   if (! positive_1)
-    {
-      rtx_code rev = rs6000_reverse_condition (GET_MODE (operands[2]),
-                                              GET_CODE (operands[1]),
-                                              order_ok);
-      gcc_assert (rev != UNKNOWN);
-      operands[1] = gen_rtx_fmt_ee (rev, SImode, operands[2], const0_rtx);
-    }
+    operands[1] = gen_rtx_fmt_ee (rs6000_reverse_condition (GET_MODE 
(operands[2]),
+                                                           GET_CODE 
(operands[1])),
+                                 SImode,
+                                 operands[2], const0_rtx);
   else if (GET_MODE (operands[1]) != SImode)
     operands[1] = gen_rtx_fmt_ee (GET_CODE (operands[1]), SImode,
                                  operands[2], const0_rtx);
 
   if (! positive_2)
-    {
-      rtx_code rev = rs6000_reverse_condition (GET_MODE (operands[4]),
-                                              GET_CODE (operands[3]),
-                                              order_ok);
-      gcc_assert (rev != UNKNOWN);
-      operands[3] = gen_rtx_fmt_ee (rev, SImode, operands[4], const0_rtx);
-    }
+    operands[3] = gen_rtx_fmt_ee (rs6000_reverse_condition (GET_MODE 
(operands[4]),
+                                                           GET_CODE 
(operands[3])),
+                                 SImode,
+                                 operands[4], const0_rtx);
   else if (GET_MODE (operands[3]) != SImode)
     operands[3] = gen_rtx_fmt_ee (GET_CODE (operands[3]), SImode,
                                  operands[4], const0_rtx);
diff --git a/gcc/testsuite/gcc.target/powerpc/pr118541.c 
b/gcc/testsuite/gcc.target/powerpc/pr118541.c
deleted file mode 100644
index a38c94c8b7ed..000000000000
--- a/gcc/testsuite/gcc.target/powerpc/pr118541.c
+++ /dev/null
@@ -1,147 +0,0 @@
-/* { dg-do compile } */
-/* { dg-options "-mdejagnu-cpu=power9 -O2" } */
-/* { dg-require-effective-target powerpc_vsx } */
-
-/* PR target/118541 says that the ordered comparison functions like isgreater
-   should not optimize floating point conditional moves to use
-   x{s,v}cmp{eq,gt,ge}{dp,qp} and xxsel since that instruction can cause traps
-   if one of the arguments is a signaling NaN.  */
-
-/* Verify isgreater, isgreaterequal, isless, and islessequal does not generate
-   xscmpltdp, xscmpgtdp, or xscmpeqdp.  */
-
-double
-ordered_gt (double a, double b, double c, double d)
-{
-  /*
-   * fcmpu 0,1,2
-   * fmr 1,4
-   * bnglr 0
-   * fmr 1,3
-   * blr
-   */
-
-  return __builtin_isgreater (a, b) ? c : d;
-}
-
-double
-ordered_ge (double a, double b, double c, double d)
-{
-  /*
-   * fcmpu 0,1,2
-   * fmr 1,4
-   * cror 2,0,3
-   * beqlr 0
-   * fmr 1,3
-   * blr
-   */
-
-  return __builtin_isgreaterequal (a, b) ? c : d;
-}
-
-double
-ordered_lt (double a, double b, double c, double d)
-{
-  /*
-   * fcmpu 0,1,2
-   * fmr 1,4
-   * bnllr 0
-   * fmr 1,3
-   * blr
-   */
-
-  return __builtin_isless (a, b) ? c : d;
-}
-
-double
-ordered_le (double a, double b, double c, double d)
-{
-  /*
-   * fcmpu 0,1,2
-   * fmr 1,4
-   * cror 2,1,3
-   * beqlr 0
-   * fmr 1,3
-   * blr
-   */
-
-  return __builtin_islessequal (a, b) ? c : d;
-}
-
-double
-normal_gt (double a, double b, double c, double d)
-{
-  /*
-   * xscmpgtdp 1,1,2
-   * xxsel 1,4,3,1
-   * blr
-   */
-
-  return a > b ? c : d;
-}
-
-double
-normal_ge (double a, double b, double c, double d)
-{
-  /*
-   * xscmpgedp 1,1,2
-   * xxsel 1,4,3,1
-   * blr
-   */
-
-  return a >= b ? c : d;
-}
-
-double
-normal_lt (double a, double b, double c, double d)
-{
-  /*
-   * xscmpgtdp 1,2,1
-   * xxsel 1,4,3,1
-   * blr
-   */
-
-  return a < b ? c : d;
-}
-
-double
-normal_le (double a, double b, double c, double d)
-{
-  /*
-   * xscmpgedp 1,2,1
-   * xxsel 1,4,3,1
-   * blr
-   */
-
-  return a <= b ? c : d;
-}
-
-double
-normal_eq (double a, double b, double c, double d)
-{
-  /*
-   * xscmpeqdp 1,1,2
-   * xxsel 1,4,3,1
-   * blr
-   */
-
-  return a == b ? c : d;
-}
-
-double
-normal_ne (double a, double b, double c, double d)
-{
-  /*
-   * xscmpeqdp 1,1,2
-   * xxsel 1,3,4,1
-   * blr
-   */
-
-  return a != b ? c : d;
-}
-
-/* { dg-final { scan-assembler-times {\mxscmpudp\M|\mfcmpu\M} 4 } } */
-/* { dg-final { scan-assembler-times {\mxscmpeqdp\M}          2 } } */
-/* { dg-final { scan-assembler-times {\mxscmpgedp\M}          2 } } */
-/* { dg-final { scan-assembler-times {\mxscmpgtdp\M}          2 } } */
-/* { dg-final { scan-assembler-times {\mxxsel\M}              6 } } */

Reply via email to