expmed.c (emit_store_flag): If comparing two-word integer with zero, can optimize...
authorRichard Kenner <kenner@vlsi1.ultra.nyu.edu>
Tue, 18 Apr 2000 19:14:58 +0000 (15:14 -0400)
committerRichard Kenner <kenner@gcc.gnu.org>
Tue, 18 Apr 2000 19:14:58 +0000 (15:14 -0400)
* expmed.c (emit_store_flag): If comparing two-word integer
with zero, can optimize NE, EQ, GE, and LT.

From-SVN: r33230

gcc/ChangeLog
gcc/expmed.c

index 0ba9d8b55be689fd567b7829969fae2941f4a190..d9eb7c4b0c38b50f648b87d4d386fe5b73f291f1 100644 (file)
@@ -1,14 +1,17 @@
-2000-04-18  Mark Mitchell  <mark@codesourcery.com>
-
-       * 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  <kenner@vlsi1.ultra.nyu.edu>
 
+       * 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  <mark@codesourcery.com>
+
+       * cpplex.c (_cpp_lex_token): Don't call CPP_BUMP_LINE when the
+       mark is active.
 
 2000-04-17  Zack Weinberg  <zack@wolery.cumb.org>
 
index 16c9bef6b5f90fea3e8b253d9a0ff5e551c07b0e..bb06536e5e59a208498fd8e42e3fdb72f998798e 100644 (file)
@@ -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];