aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorKewen Lin <linkw@linux.ibm.com>2022-04-05 22:18:30 -0500
committerKewen Lin <linkw@linux.ibm.com>2022-04-05 22:18:30 -0500
commit83b43c74bbbdc6b6903350b220b932c6f774bdfd (patch)
treef52493d6832c2513e0e32d760107fe610e548bdd /gcc
parent9d84ed6812dce4a50e64334e7cc4abdeebe41523 (diff)
downloadgcc-83b43c74bbbdc6b6903350b220b932c6f774bdfd.zip
gcc-83b43c74bbbdc6b6903350b220b932c6f774bdfd.tar.gz
gcc-83b43c74bbbdc6b6903350b220b932c6f774bdfd.tar.bz2
rs6000: Support UN[GL][ET] in rs6000_maybe_emit_maxc_minc [PR105002]
Commit r12-7687 exposed one miss optimization chance in function rs6000_maybe_emit_maxc_minc, for now it only considers comparison codes GE/GT/LE/LT, but it can support more variants with codes UNLT/UNLE/UNGT/UNGE by reversing them into the equivalent ones with GE/GT/LE/LT. gcc/ChangeLog: PR target/105002 * config/rs6000/rs6000.cc (rs6000_maybe_emit_maxc_minc): Support more comparison codes UNLT/UNLE/UNGT/UNGE.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/config/rs6000/rs6000.cc21
1 files changed, 20 insertions, 1 deletions
diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc
index cb18db0..ceaddaf 100644
--- a/gcc/config/rs6000/rs6000.cc
+++ b/gcc/config/rs6000/rs6000.cc
@@ -15867,11 +15867,30 @@ rs6000_maybe_emit_maxc_minc (rtx dest, rtx op, rtx true_cond, rtx false_cond)
rtx op1 = XEXP (op, 1);
machine_mode compare_mode = GET_MODE (op0);
machine_mode result_mode = GET_MODE (dest);
- bool max_p = false;
if (result_mode != compare_mode)
return false;
+ /* See the comments of this function, it simply expects GE/GT/LE/LT in
+ the checks, but for the reversible equivalent UNLT/UNLE/UNGT/UNGE,
+ we need to do the reversions first to make the following checks
+ support fewer cases, like:
+
+ (a UNLT b) ? op1 : op2 => (a >= b) ? op2 : op1;
+ (a UNLE b) ? op1 : op2 => (a > b) ? op2 : op1;
+ (a UNGT b) ? op1 : op2 => (a <= b) ? op2 : op1;
+ (a UNGE b) ? op1 : op2 => (a < b) ? op2 : op1;
+
+ By the way, if we see these UNLT/UNLE/UNGT/UNGE it's guaranteed
+ that we have 4-way condition codes (LT/GT/EQ/UN), so we do not
+ have to check for fast-math or the like. */
+ if (code == UNGE || code == UNGT || code == UNLE || code == UNLT)
+ {
+ code = reverse_condition_maybe_unordered (code);
+ std::swap (true_cond, false_cond);
+ }
+
+ bool max_p;
if (code == GE || code == GT)
max_p = true;
else if (code == LE || code == LT)