aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMarkus Trippelsdorf <markus@trippelsdorf.de>2016-11-30 07:30:55 +0000
committerMarkus Trippelsdorf <trippels@gcc.gnu.org>2016-11-30 07:30:55 +0000
commitced17de64000713e99af200bb9ff468b907ec1f9 (patch)
tree58329b3b6437635ddd11d472f913badec576d090 /gcc
parenta4f15a7d4557811b8e5fef05a105cd68daa41a84 (diff)
downloadgcc-ced17de64000713e99af200bb9ff468b907ec1f9.zip
gcc-ced17de64000713e99af200bb9ff468b907ec1f9.tar.gz
gcc-ced17de64000713e99af200bb9ff468b907ec1f9.tar.bz2
Fix PR78588 - rtlanal.c:5210:38: runtime error: shift exponent 4294967295 is too large for 64-bit type
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. PR rtl-optimization/78588 * combine.c (if_then_else_cond): Also guard against BLKmode. * rtlanal.c (num_sign_bit_copies1): Add assert. From-SVN: r242997
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/combine.c2
-rw-r--r--gcc/rtlanal.c2
3 files changed, 9 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index a5b191b..48862fb 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2016-11-30 Markus Trippelsdorf <markus@trippelsdorf.de>
+
+ PR rtl-optimization/78588
+ * combine.c (if_then_else_cond): Also guard against BLKmode.
+ * rtlanal.c (num_sign_bit_copies1): Add assert.
+
2016-11-29 Jeff Law <law@redhat.com>
* common/config/arc/arc-common.c (arc_handle_option): Remove unused
diff --git a/gcc/combine.c b/gcc/combine.c
index 22fb7a9..a32a0ec 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;
diff --git a/gcc/rtlanal.c b/gcc/rtlanal.c
index 4e4eb2e..60550ad 100644
--- a/gcc/rtlanal.c
+++ b/gcc/rtlanal.c
@@ -4840,6 +4840,8 @@ num_sign_bit_copies1 (const_rtx x, machine_mode mode, const_rtx known_x,
if (mode == VOIDmode)
mode = GET_MODE (x);
+ gcc_checking_assert (mode != BLKmode);
+
if (mode == VOIDmode || FLOAT_MODE_P (mode) || FLOAT_MODE_P (GET_MODE (x))
|| VECTOR_MODE_P (GET_MODE (x)) || VECTOR_MODE_P (mode))
return 1;