re PR middle-end/16795 (PowerPC - Divide sequences by negative power of two could...
authorDavid Edelsohn <edelsohn@gnu.org>
Sun, 12 Sep 2004 20:05:30 +0000 (20:05 +0000)
committerDavid Edelsohn <dje@gcc.gnu.org>
Sun, 12 Sep 2004 20:05:30 +0000 (16:05 -0400)
        PR target/16795
        * expmed.c (expand_divmod): If cheap power of 2 divide is
        available, use it for negative constant as well.

From-SVN: r87403

gcc/ChangeLog
gcc/expmed.c

index c7d9ee140816bd5a006f067eebd327c33d4a0006..1c3b7affc1dfc24cd89786d324c9025371d45d56 100644 (file)
@@ -1,3 +1,9 @@
+2004-09-12  David Edelsohn  <edelsohn@gnu.org>
+
+       PR target/16795
+       * expmed.c (expand_divmod): If cheap power of 2 divide is
+       available, use it for negative constant as well.
+
 2004-09-12  Andrew Pinski  <apinski@apple.com>
 
        * darwin.h (ASM_OUTPUT_COMMON): Make sure we do not have a
index fe9aeb5c4c9b4fa541c4f4c07ce0877b4156da6e..eb8226da75f35294fc9e5340f7e067c6231fa85c 100644 (file)
@@ -3764,7 +3764,19 @@ expand_divmod (int rem_flag, enum tree_code code, enum machine_mode mode,
                        if (remainder)
                          return gen_lowpart (mode, remainder);
                      }
-                   quotient = expand_sdiv_pow2 (compute_mode, op0, abs_d);
+
+                   if (sdiv_pow2_cheap[compute_mode]
+                       && ((sdiv_optab->handlers[compute_mode].insn_code
+                            != CODE_FOR_nothing)
+                           || (sdivmod_optab->handlers[compute_mode].insn_code
+                               != CODE_FOR_nothing)))
+                     quotient = expand_divmod (0, TRUNC_DIV_EXPR,
+                                               compute_mode, op0,
+                                               gen_int_mode (abs_d,
+                                                             compute_mode),
+                                               NULL_RTX, 0);
+                   else
+                     quotient = expand_sdiv_pow2 (compute_mode, op0, abs_d);
 
                    /* We have computed OP0 / abs(OP1).  If OP1 is negative,
                       negate the quotient.  */