Useless test in gen_binary

Bonzini bonzini@gnu.org
Tue Feb 10 15:54:00 GMT 2004


While setting a battle plan to kill gen_binary, I noticed this code:

diff -u -r1.367 -r1.368
--- combine.c   5 Jul 2003 21:10:08 -0000       1.367
+++ combine.c   10 Jul 2003 20:28:09 -0000      1.368
@@ -10171,6 +10171,11 @@
   rtx result;
   rtx tem;
 
+  if (GET_CODE (op0) == CLOBBER)
+    return op0;
+  else if (GET_CODE (op1) == CLOBBER)
+    return op1;
+  
   if (GET_RTX_CLASS (code) == 'c'
       && swap_commutative_operands_p (op0, op1))
     tem = op0, op0 = op1, op1 = tem;

by Denis Chertykov and Richard Kenner.  It is supposed to fix PR11181,
but it is useless because Eric Botcazou committed this patch to fix
PR11381 about at the same time:

Index: simplify-rtx.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/simplify-rtx.c,v
retrieving revision 1.144
retrieving revision 1.145
diff -u -r1.144 -r1.145
--- simplify-rtx.c      17 Jun 2003 00:02:06 -0000      1.144
+++ simplify-rtx.c      3 Jul 2003 07:30:00 -0000       1.145
@@ -2220,8 +2220,10 @@
     return const0_rtx;
 
   /* For modes without NaNs, if the two operands are equal, we know the
-     result.  */
-  if (!HONOR_NANS (GET_MODE (trueop0)) && rtx_equal_p (trueop0, trueop1))
+     result except if they have side-effects.  */
+  if (! HONOR_NANS (GET_MODE (trueop0))
+      && rtx_equal_p (trueop0, trueop1)
+      && ! side_effects_p (trueop0))
     equal = 1, op0lt = 0, op0ltu = 0, op1lt = 0, op1ltu = 0;
 
   /* If the operands are floating-point constants, see if we can fold

The two PR's are quite different: in PR11181 simplify-rtx did not
understand the bogus CLOBBERS emitted by combine, while in PR11381
trueop0 had side effects because it was a volatile reference.  However,
PR11181's testcase indeed does not fail with only Eric's fix applied
(with a cross to avr-elf).

Would it be ok if I killed the hunk in combine.c as part of removing
gen_binary?

Paolo



More information about the Gcc mailing list