This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[cond-optab, trunk] Always use comparison for division by large unsigned integer


On cond-optab branch we get a division libcall instead of a comparison
libcall for the -O0 test unsigned-long-compare.c on powerpc.  The same
behavior is there for the following similar testcase (also at -O0 only):

#define BIG_CONSTANT 0xFFFFFFFF80000000ULL

int main (int argc)
{
  unsigned long long OneULL = 1ULL;
  unsigned long long result;

  result = argc / BIG_CONSTANT;
  if (result)
    abort ();
  exit (0);
}

This is because emit_store_flag looks for sgeu patterns on trunk
(present) and for cstoredi4 patterns on branch (absent).  However, in
this particular case it is anyway possible to avoid a libcall, which is
what this patch does.

Bootstrap/regtest in progress, ok?

Paolo
2009-04-09  Paolo Bonzini  <bonzini@gnu.org>

	* expmed.c (expand_divmod): Always use a comparison for a division
	by a large unsigned integer.

Index: gcc/expmed.c
===================================================================
--- gcc/expmed.c	(branch cond-optab)
+++ gcc/expmed.c	(working copy)
@@ -3998,10 +3998,8 @@ expand_divmod (int rem_flag, enum tree_c
 		      {
 			/* Most significant bit of divisor is set; emit an scc
 			   insn.  */
-			quotient = emit_store_flag (tquotient, GEU, op0, op1,
-						    compute_mode, 1, 1);
-			if (quotient == 0)
-			  goto fail1;
+			quotient = emit_store_flag_force (tquotient, GEU, op0, op1,
+							  compute_mode, 1, 1);
 		      }
 		    else
 		      {

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]