Patchwork canonicalize_condition vs zero_extract

login
register
mail settings
Submitter DJ Delorie
Date July 2, 2010, 8:57 p.m.
Message ID <201007022057.o62KvrYg014343@greed.delorie.com>
Download mbox | patch
Permalink /patch/57775/
State New
Headers show

Comments

DJ Delorie - July 2, 2010, 8:57 p.m.
> > * Check for a generic "this rtl has more than 2 xexp's"?
> 
> This is better done...
> 
> ... by simply checking for COMPARISON_P.

Patch attached.  OK to apply?  Tested by building the RX libraries and
seeing no ICEs.

> > * Find out why a zero_extract is getting this far in the first place?
> 
> This also sounds like a good idea.  Maybe a small testcase and a 
> backtrace will be enough?

I haven't submitted that patch yet.  Basically, this code:

	if (a & 4) ...

with a target that uses TST insead of AND or CMP, gcc tries to make an
(if_then_else (zero_extract ...) ...) expression, which causes the
problems.



2010-07-02  DJ Delorie  <dj@redhat.com>

	* rtlanal.c (canonicalize_condition): Avoid non-comparison RTX.

Patch

Index: rtlanal.c
===================================================================
--- rtlanal.c	(revision 161744)
+++ rtlanal.c	(working copy)
@@ -4694,12 +4694,17 @@  canonicalize_condition (rtx insn, rtx co
   rtx tem;
   rtx op0, op1;
   int reverse_code = 0;
   enum machine_mode mode;
   basic_block bb = BLOCK_FOR_INSN (insn);
 
+  /* Single-bit tests sometimes use logic ops to generate the
+     condition, rather than comparisons.  */
+  if (! COMPARISON_P (cond))
+    return 0;
+
   code = GET_CODE (cond);
   mode = GET_MODE (cond);
   op0 = XEXP (cond, 0);
   op1 = XEXP (cond, 1);
 
   if (reverse)