public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Eric Botcazou <ebotcazou@adacore.com>
To: Jeff Law <law@redhat.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [patch] Fix ICE on ACATS test for Aarch64 at -O
Date: Mon, 26 Sep 2016 07:33:00 -0000	[thread overview]
Message-ID: <4485071.DuJRMUeJTt@polaris> (raw)
In-Reply-To: <73ddb77a-0c10-f73b-25e6-9088acdd139b@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 520 bytes --]

> So while emit_store_flag_force knows what to do upon NULL return, I'm
> not sure the other users of expand_shift/expand_shift_1 do.  

Revised patch attached, tested on x86-64/Linux, OK for the mainline?


2016-09-26  Eric Botcazou  <ebotcazou@adacore.com>

	* expmed.c (expand_shift_1): Add MAY_FAIL parameter and do not assert
	that the result is non-zero if it is true.
	(maybe_expand_shift): New wrapper around expand_shift_1.
	(emit_store_flag): Call maybe_expand_shift in lieu of expand_shift.

-- 
Eric Botcazou

[-- Attachment #2: p.diff --]
[-- Type: text/x-patch, Size: 2599 bytes --]

Index: expmed.c
===================================================================
--- expmed.c	(revision 240311)
+++ expmed.c	(working copy)
@@ -2247,11 +2247,13 @@ expand_dec (rtx target, rtx dec)
    and AMOUNT the rtx for the amount to shift by.
    Store the result in the rtx TARGET, if that is convenient.
    If UNSIGNEDP is nonzero, do a logical shift; otherwise, arithmetic.
-   Return the rtx for where the value is.  */
+   Return the rtx for where the value is.
+   If that cannot be done, abort the compilation unless MAY_FAIL is true,
+   in which case 0 is returned.  */
 
 static rtx
 expand_shift_1 (enum tree_code code, machine_mode mode, rtx shifted,
-		rtx amount, rtx target, int unsignedp)
+		rtx amount, rtx target, int unsignedp, bool may_fail = false)
 {
   rtx op1, temp = 0;
   int left = (code == LSHIFT_EXPR || code == LROTATE_EXPR);
@@ -2448,7 +2450,7 @@ expand_shift_1 (enum tree_code code, mac
 	 define_expand for lshrsi3 was added to vax.md.  */
     }
 
-  gcc_assert (temp);
+  gcc_assert (temp != NULL_RTX || may_fail);
   return temp;
 }
 
@@ -2467,6 +2469,16 @@ expand_shift (enum tree_code code, machi
 			 shifted, GEN_INT (amount), target, unsignedp);
 }
 
+/* Likewise, but return 0 if that cannot be done.  */
+
+static rtx
+maybe_expand_shift (enum tree_code code, machine_mode mode, rtx shifted,
+		    int amount, rtx target, int unsignedp)
+{
+  return expand_shift_1 (code, mode,
+			 shifted, GEN_INT (amount), target, unsignedp, true);
+}
+
 /* Output a shift instruction for expression code CODE,
    with SHIFTED being the rtx for the value to shift,
    and AMOUNT the tree for the amount to shift by.
@@ -5753,11 +5765,12 @@ emit_store_flag (rtx target, enum rtx_co
       if (rtx_equal_p (subtarget, op0))
 	subtarget = 0;
 
-      tem = expand_shift (RSHIFT_EXPR, mode, op0,
-			  GET_MODE_BITSIZE (mode) - 1,
-			  subtarget, 0);
-      tem = expand_binop (mode, sub_optab, tem, op0, subtarget, 0,
-			  OPTAB_WIDEN);
+      tem = maybe_expand_shift (RSHIFT_EXPR, mode, op0,
+				GET_MODE_BITSIZE (mode) - 1,
+				subtarget, 0);
+      if (tem)
+	tem = expand_binop (mode, sub_optab, tem, op0, subtarget, 0,
+			    OPTAB_WIDEN);
     }
 
   if (code == EQ || code == NE)
@@ -5819,9 +5832,9 @@ emit_store_flag (rtx target, enum rtx_co
     }
 
   if (tem && normalizep)
-    tem = expand_shift (RSHIFT_EXPR, mode, tem,
-			GET_MODE_BITSIZE (mode) - 1,
-			subtarget, normalizep == 1);
+    tem = maybe_expand_shift (RSHIFT_EXPR, mode, tem,
+			      GET_MODE_BITSIZE (mode) - 1,
+			      subtarget, normalizep == 1);
 
   if (tem)
     {

  parent reply	other threads:[~2016-09-26  6:44 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-16 23:55 Eric Botcazou
2016-09-19 17:14 ` Jeff Law
2016-09-21 14:02   ` Eric Botcazou
2016-09-26  7:33   ` Eric Botcazou [this message]
2016-10-03 15:45     ` Eric Botcazou
2016-10-17 18:04       ` Jeff Law
2016-10-11  7:28     ` Eric Botcazou
2016-10-11 21:20     ` Eric Botcazou

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=4485071.DuJRMUeJTt@polaris \
    --to=ebotcazou@adacore.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=law@redhat.com \
    /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).