From: Markus Trippelsdorf <markus@trippelsdorf.de>
To: gcc-patches@gcc.gnu.org
Cc: Jakub Jelinek <jakub@redhat.com>,
Segher Boessenkool <segher@kernel.crashing.org>
Subject: Re: [PATCH v2] Fix PR78588 - rtlanal.c:5210:38: runtime error: shift exponent 4294967295 is too large for 64-bit type
Date: Tue, 29 Nov 2016 16:00:00 -0000 [thread overview]
Message-ID: <20161129160005.GE441@x4> (raw)
In-Reply-To: <20161129140815.GA441@x4>
Here is v2 of the fix.
Building gcc with -fsanitize=undefined shows:
rtlanal.c:5210:38: runtime error: shift exponent 4294967295 is too large for 64-bit type 'long unsigned int'
This happens because if_then_else_cond() in combine.c calls
num_sign_bit_copies() in rtlanal.c with mode==BLKmode.
5205 bitwidth = GET_MODE_PRECISION (mode);
5206 if (bitwidth > HOST_BITS_PER_WIDE_INT)
5207 return 1;
5208
5209 nonzero = nonzero_bits (x, mode);
5210 return nonzero & (HOST_WIDE_INT_1U << (bitwidth - 1))
5211 ? 1 : bitwidth - floor_log2 (nonzero) - 1;
This causes (bitwidth - 1) to wrap around.
Fix by also guarding against BLKmode.
Tested on pcc64le.
OK for trunk?
Thanks.
PR rtl-optimization/78588
* combine.c (if_then_else_cond): Also guard against BLKmode.
diff --git a/gcc/combine.c b/gcc/combine.c
index 22fb7a976538..a32a0ecc72fb 100644
--- a/gcc/combine.c
+++ b/gcc/combine.c
@@ -9176,7 +9176,7 @@ if_then_else_cond (rtx x, rtx *ptrue, rtx *pfalse)
/* If X is known to be either 0 or -1, those are the true and
false values when testing X. */
else if (x == constm1_rtx || x == const0_rtx
- || (mode != VOIDmode
+ || (mode != VOIDmode && mode != BLKmode
&& num_sign_bit_copies (x, mode) == GET_MODE_PRECISION (mode)))
{
*ptrue = constm1_rtx, *pfalse = const0_rtx;
--
Markus
next prev parent reply other threads:[~2016-11-29 16:00 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-29 14:08 [PATCH] " Markus Trippelsdorf
2016-11-29 14:14 ` Jakub Jelinek
2016-11-29 14:21 ` Markus Trippelsdorf
2016-11-29 15:01 ` Markus Trippelsdorf
2016-11-29 15:07 ` Markus Trippelsdorf
2016-11-29 16:00 ` Markus Trippelsdorf [this message]
2016-11-29 21:25 ` [PATCH v2] " Segher Boessenkool
2016-11-30 7:34 ` Markus Trippelsdorf
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=20161129160005.GE441@x4 \
--to=markus@trippelsdorf.de \
--cc=gcc-patches@gcc.gnu.org \
--cc=jakub@redhat.com \
--cc=segher@kernel.crashing.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).