aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Kenner <kenner@gcc.gnu.org>1995-12-10 10:06:28 -0500
committerRichard Kenner <kenner@gcc.gnu.org>1995-12-10 10:06:28 -0500
commit5be669c75aa8ce429cc008c1b4e10aaafc34c273 (patch)
treeee11a9109b152f74fadec1a943ab50a2bca5d975 /gcc
parent05019f83a3c585af22a1b275c71b3bc8239cd552 (diff)
downloadgcc-5be669c75aa8ce429cc008c1b4e10aaafc34c273.zip
gcc-5be669c75aa8ce429cc008c1b4e10aaafc34c273.tar.gz
gcc-5be669c75aa8ce429cc008c1b4e10aaafc34c273.tar.bz2
(simplify_if_then_else): Convert "a == b ? b : a" to "a".
From-SVN: r10698
Diffstat (limited to 'gcc')
-rw-r--r--gcc/combine.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/gcc/combine.c b/gcc/combine.c
index 473adc8..df8c732 100644
--- a/gcc/combine.c
+++ b/gcc/combine.c
@@ -4025,6 +4025,16 @@ simplify_if_then_else (x)
if (rtx_equal_p (true, false) && ! side_effects_p (cond))
return true;
+ /* Convert a == b ? b : a to "a". */
+ if (true_code == EQ && ! side_effects_p (cond)
+ && rtx_equal_p (XEXP (cond, 0), false)
+ && rtx_equal_p (XEXP (cond, 1), true))
+ return false;
+ else if (true_code == NE && ! side_effects_p (cond)
+ && rtx_equal_p (XEXP (cond, 0), true)
+ && rtx_equal_p (XEXP (cond, 1), false))
+ return true;
+
/* Look for cases where we have (abs x) or (neg (abs X)). */
if (GET_MODE_CLASS (mode) == MODE_INT