public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: Richard Henderson <rth@redhat.com>
To: nobody@gcc.gnu.org
Cc: gcc-prs@gcc.gnu.org,
Subject: Re: optimization/7147: ifcvt.c problem (regression)
Date: Tue, 16 Jul 2002 14:36:00 -0000	[thread overview]
Message-ID: <20020716213601.24179.qmail@sources.redhat.com> (raw)

The following reply was made to PR optimization/7147; it has been noted by GNATS.

From: Richard Henderson <rth@redhat.com>
To: Franz Sirl <Franz.Sirl-kernel@lauterbach.com>
Cc: gcc-gnats@gcc.gnu.org, gcc-patches@gcc.gnu.org,
   Mark Mitchell <mark@codesourcery.com>
Subject: Re: optimization/7147: ifcvt.c problem (regression)
Date: Tue, 16 Jul 2002 14:27:52 -0700

 This looks like fallout from 
 
 2002-05-03  Richard Henderson  <rth@redhat.com>
 
         PR opt/6534
         * ifcvt.c (noce_try_store_flag, noce_try_store_flag_constants,
         noce_try_store_flag_inc, noce_try_store_flag_mask, noce_try_cmove,
         noce_try_cmove_arith, noce_try_minmax, noce_try_abs): Insert new
         code before JUMP, not EARLIEST.
 
 I'm testing the following on x86.  Give it a whirl on ppc as well?
 
 
 r~
 
 
 	* ifcvt.c (noce_get_condition): Make certain that the condition
 	is valid at JUMP.
 
 Index: ifcvt.c
 ===================================================================
 RCS file: /cvs/gcc/gcc/gcc/ifcvt.c,v
 retrieving revision 1.78.2.5
 diff -c -p -d -r1.78.2.5 ifcvt.c
 *** ifcvt.c	3 May 2002 20:24:01 -0000	1.78.2.5
 --- ifcvt.c	16 Jul 2002 21:21:30 -0000
 *************** noce_try_abs (if_info)
 *** 1504,1548 ****
     return TRUE;
   }
   
 ! /* Look for the condition for the jump first.  We'd prefer to avoid
 !    get_condition if we can -- it tries to look back for the contents
 !    of an original compare.  On targets that use normal integers for
 !    comparisons, e.g. alpha, this is wasteful.  */
   
   static rtx
   noce_get_condition (jump, earliest)
        rtx jump;
        rtx *earliest;
   {
 !   rtx cond;
 !   rtx set;
 ! 
 !   /* If the condition variable is a register and is MODE_INT, accept it.
 !      Otherwise, fall back on get_condition.  */
   
     if (! any_condjump_p (jump))
       return NULL_RTX;
   
     set = pc_set (jump);
   
     cond = XEXP (SET_SRC (set), 0);
 !   if (GET_CODE (XEXP (cond, 0)) == REG
 !       && GET_MODE_CLASS (GET_MODE (XEXP (cond, 0))) == MODE_INT)
       {
         *earliest = jump;
   
 !       /* If this branches to JUMP_LABEL when the condition is false,
 ! 	 reverse the condition.  */
 !       if (GET_CODE (XEXP (SET_SRC (set), 2)) == LABEL_REF
 ! 	  && XEXP (XEXP (SET_SRC (set), 2), 0) == JUMP_LABEL (jump))
   	cond = gen_rtx_fmt_ee (reverse_condition (GET_CODE (cond)),
 ! 			       GET_MODE (cond), XEXP (cond, 0),
 ! 			       XEXP (cond, 1));
       }
 -   else
 -     cond = get_condition (jump, earliest);
   
 !   return cond;
   }
   
   /* Return true if OP is ok for if-then-else processing.  */
 --- 1504,1576 ----
     return TRUE;
   }
   
 ! /* Similar to get_condition, only the resulting condition must be
 !    valid at JUMP, instead of at EARLIEST.  */
   
   static rtx
   noce_get_condition (jump, earliest)
        rtx jump;
        rtx *earliest;
   {
 !   rtx cond, set, tmp, insn;
 !   bool reverse;
   
     if (! any_condjump_p (jump))
       return NULL_RTX;
   
     set = pc_set (jump);
   
 +   /* If this branches to JUMP_LABEL when the condition is false,
 +      reverse the condition.  */
 +   reverse = (GET_CODE (XEXP (SET_SRC (set), 2)) == LABEL_REF
 + 	     && XEXP (XEXP (SET_SRC (set), 2), 0) == JUMP_LABEL (jump));
 + 
 +   /* If the condition variable is a register and is MODE_INT, accept it.  */
 + 
     cond = XEXP (SET_SRC (set), 0);
 !   tmp = XEXP (cond, 0);
 !   if (REG_P (tmp) && GET_MODE_CLASS (GET_MODE (tmp)) == MODE_INT)
       {
         *earliest = jump;
   
 !       if (reverse)
   	cond = gen_rtx_fmt_ee (reverse_condition (GET_CODE (cond)),
 ! 			       GET_MODE (cond), tmp, XEXP (cond, 1));
 !       return cond;
       }
   
 !   /* Otherwise, fall back on canonicalize_condition to do the dirty
 !      work of manipulating MODE_CC values and COMPARE rtx codes.  */
 ! 
 !   tmp = canonicalize_condition (jump, cond, reverse, earliest, NULL_RTX);
 !   if (!tmp)
 !     return NULL_RTX;
 ! 
 !   /* We are going to insert code before JUMP, not before EARLIEST.
 !      We must therefore be certain that the given condition is valid
 !      at JUMP by virtue of not having been modified since.  */
 !   for (insn = *earliest; insn != jump; insn = NEXT_INSN (insn))
 !     if (INSN_P (insn) && modified_in_p (tmp, insn))
 !       break;
 !   if (insn == jump)
 !     return tmp;
 ! 
 !   /* The condition was modified.  See if we can get a partial result
 !      that doesn't follow all the reversals.  Perhaps combine can fold
 !      them together later.  */
 !   tmp = XEXP (tmp, 0);
 !   if (!REG_P (tmp) || GET_MODE_CLASS (GET_MODE (tmp)) != MODE_INT)
 !     return NULL_RTX;
 !   tmp = canonicalize_condition (jump, cond, reverse, earliest, tmp);
 !   if (!tmp)
 !     return NULL_RTX;
 ! 
 !   /* For sanity's sake, re-validate the new result.  */
 !   for (insn = *earliest; insn != jump; insn = NEXT_INSN (insn))
 !     if (INSN_P (insn) && modified_in_p (tmp, insn))
 !       return NULL_RTX;
 ! 
 !   return tmp;
   }
   
   /* Return true if OP is ok for if-then-else processing.  */


             reply	other threads:[~2002-07-16 21:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-07-16 14:36 Richard Henderson [this message]
  -- strict thread matches above, loose matches on Subject: below --
2002-09-29  9:42 sayle
2002-07-18  6:26 Mark Mitchell
2002-07-18  6:06 Franz Sirl
2002-06-30 19:06 Franz Sirl
2002-06-27 16:06 Franz.Sirl-kernel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20020716213601.24179.qmail@sources.redhat.com \
    --to=rth@redhat.com \
    --cc=gcc-prs@gcc.gnu.org \
    --cc=nobody@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).