From b1a827517a7268706919eeef7960db247307feb0 Mon Sep 17 00:00:00 2001 From: Claudiu Zissulescu Date: Thu, 12 Nov 2015 10:28:19 +0100 Subject: [PATCH] arc.c (gen_compare_reg): Swap operands also when we do not expand to rtl. 2015-11-11 Claudiu Zissulescu * config/arc/arc.c (gen_compare_reg): Swap operands also when we do not expand to rtl. From-SVN: r230217 --- gcc/ChangeLog | 5 +++++ gcc/config/arc/arc.c | 16 +++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d292656e8d1..dd5df906212 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2015-11-12 Claudiu Zissulescu + + * config/arc/arc.c (gen_compare_reg): Swap operands also when we + do not expand to rtl. + 2015-11-12 Richard Biener PR tree-optimization/58497 diff --git a/gcc/config/arc/arc.c b/gcc/config/arc/arc.c index 85d53e4d2e3..8bb0969f176 100644 --- a/gcc/config/arc/arc.c +++ b/gcc/config/arc/arc.c @@ -1690,6 +1690,7 @@ gen_compare_reg (rtx comparison, machine_mode omode) { rtx op0 = gen_rtx_REG (cmode, 0); rtx op1 = gen_rtx_REG (cmode, GET_MODE_SIZE (cmode) / UNITS_PER_WORD); + bool swap = false; switch (code) { @@ -1698,15 +1699,19 @@ gen_compare_reg (rtx comparison, machine_mode omode) break; case LT: case UNGE: case LE: case UNGT: code = swap_condition (code); - tmp = x; - x = y; - y = tmp; + swap = true; break; default: gcc_unreachable (); } if (currently_expanding_to_rtl) { + if (swap) + { + tmp = x; + x = y; + y = tmp; + } emit_move_insn (op0, x); emit_move_insn (op1, y); } @@ -1714,6 +1719,11 @@ gen_compare_reg (rtx comparison, machine_mode omode) { gcc_assert (rtx_equal_p (op0, x)); gcc_assert (rtx_equal_p (op1, y)); + if (swap) + { + op0 = y; + op1 = x; + } } emit_insn (gen_cmp_float (cc_reg, gen_rtx_COMPARE (mode, op0, op1))); } -- 2.30.2