From: Richard Kenner Date: Tue, 18 Apr 2000 19:14:58 +0000 (-0400) Subject: expmed.c (emit_store_flag): If comparing two-word integer with zero, can optimize... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=6912b84bf1a10c6bc8c9c337153189a44bdce35f;p=gcc.git expmed.c (emit_store_flag): If comparing two-word integer with zero, can optimize NE, EQ, GE, and LT. * expmed.c (emit_store_flag): If comparing two-word integer with zero, can optimize NE, EQ, GE, and LT. From-SVN: r33230 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 0ba9d8b55be..d9eb7c4b0c3 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,14 +1,17 @@ -2000-04-18 Mark Mitchell - - * cpplex.c (_cpp_lex_token): Don't call CPP_BUMP_LINE when the - mark is active. - Tue Apr 18 14:16:47 2000 Richard Kenner + * expmed.c (emit_store_flag): If comparing two-word integer + with zero, can optimize NE, EQ, GE, and LT. + * c-decl.c (mark_binding_level): Use 'for' instead of `while'. * conflict.c: Minor cleanups. * optabs.c: Add blank line - * simplify-rtx.c: + * simplify-rtx.c: Minor cleanups. + +2000-04-18 Mark Mitchell + + * cpplex.c (_cpp_lex_token): Don't call CPP_BUMP_LINE when the + mark is active. 2000-04-17 Zack Weinberg diff --git a/gcc/expmed.c b/gcc/expmed.c index 16c9bef6b5f..bb06536e5e5 100644 --- a/gcc/expmed.c +++ b/gcc/expmed.c @@ -4181,6 +4181,29 @@ emit_store_flag (target, code, op0, op1, mode, unsignedp, normalizep) break; } + /* If we are comparing a double-word integer with zero, we can convert + the comparison into one involving a single word. */ + if (GET_MODE_BITSIZE (mode) == BITS_PER_WORD * 2 + && GET_MODE_CLASS (mode) == MODE_INT + && op1 == const0_rtx) + { + if (code == EQ || code == NE) + { + /* Do a logical OR of the two words and compare the result. */ + rtx op0h = gen_highpart (word_mode, op0); + rtx op0l = gen_lowpart (word_mode, op0); + rtx op0both = expand_binop (word_mode, ior_optab, op0h, op0l, + NULL_RTX, unsignedp, OPTAB_DIRECT); + if (op0both != 0) + return emit_store_flag (target, code, op0both, op1, word_mode, + unsignedp, normalizep); + } + else if (code == LT || code == GE) + /* If testing the sign bit, can just test on high word. */ + return emit_store_flag (target, code, gen_highpart (word_mode, op0), + op1, word_mode, unsignedp, normalizep); + } + /* From now on, we won't change CODE, so set ICODE now. */ icode = setcc_gen_code[(int) code];