aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Kenner <kenner@gcc.gnu.org>1993-01-27 19:23:02 -0500
committerRichard Kenner <kenner@gcc.gnu.org>1993-01-27 19:23:02 -0500
commitc2615a67c76b0f94c16ab8c872a7132995ee3219 (patch)
tree5fc41e1ed4c897ff6f277ff41c151df40cb9afb3
parentbf743ac5ed9fc641a83dc52fd0e7f099518aa647 (diff)
downloadgcc-c2615a67c76b0f94c16ab8c872a7132995ee3219.zip
gcc-c2615a67c76b0f94c16ab8c872a7132995ee3219.tar.gz
gcc-c2615a67c76b0f94c16ab8c872a7132995ee3219.tar.bz2
(emit_store_flag): Swap operands if first is a constant and second is not.
Abort if compare_from_rtx didn't return an rtx with the code we expect. From-SVN: r3371
-rw-r--r--gcc/expmed.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/gcc/expmed.c b/gcc/expmed.c
index c652d07..375b9f6 100644
--- a/gcc/expmed.c
+++ b/gcc/expmed.c
@@ -2756,6 +2756,18 @@ emit_store_flag (target, code, op0, op1, mode, unsignedp, normalizep)
if (mode == VOIDmode)
mode = GET_MODE (op0);
+ /* If one operand is constant, make it the second one. Only do this
+ if the other operand is not constant as well. */
+
+ if ((CONSTANT_P (op0) && ! CONSTANT_P (op1))
+ || (GET_CODE (op0) == CONST_INT && GET_CODE (op1) != CONST_INT))
+ {
+ tem = op0;
+ op0 = op1;
+ op1 = tem;
+ code = swap_condition (code);
+ }
+
/* For some comparisons with 1 and -1, we can convert this to
comparisons with zero. This will often produce more opportunities for
store-flag insns. */
@@ -2851,11 +2863,12 @@ emit_store_flag (target, code, op0, op1, mode, unsignedp, normalizep)
: normalizep == -1 ? constm1_rtx
: const_true_rtx);
- /* Comparison operands could have been swapped;
- so get the new comprison code.
- Note that GET_CODE gives us either the original code
- or the result of swap_condition. */
- icode = setcc_gen_code[(int) GET_CODE (comparison)];
+ /* If the code of COMPARISON doesn't match CODE, something is
+ wrong; we can no longer be sure that we have the operation.
+ We could handle this case, but it should not happen. */
+
+ if (GET_CODE (comparison) != code)
+ abort ();
/* Get a reference to the target in the proper mode for this insn. */
compare_mode = insn_operand_mode[(int) icode][0];