From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 93782 invoked by alias); 29 Nov 2016 16:00:34 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 93742 invoked by uid 89); 29 Nov 2016 16:00:30 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=5209 X-HELO: mail.ud10.udmedia.de Received: from ud10.udmedia.de (HELO mail.ud10.udmedia.de) (194.117.254.50) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 29 Nov 2016 16:00:20 +0000 Received: (qmail 12688 invoked from network); 29 Nov 2016 17:00:06 +0100 Received: from ip5b405f78.dynamic.kabel-deutschland.de (HELO x4) (ud10?360p3@91.64.95.120) by mail.ud10.udmedia.de with ESMTPSA (ECDHE-RSA-AES256-SHA encrypted, authenticated); 29 Nov 2016 17:00:06 +0100 Date: Tue, 29 Nov 2016 16:00:00 -0000 From: Markus Trippelsdorf To: gcc-patches@gcc.gnu.org Cc: Jakub Jelinek , Segher Boessenkool Subject: Re: [PATCH v2] Fix PR78588 - rtlanal.c:5210:38: runtime error: shift exponent 4294967295 is too large for 64-bit type Message-ID: <20161129160005.GE441@x4> References: <20161129140815.GA441@x4> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20161129140815.GA441@x4> X-SW-Source: 2016-11/txt/msg02896.txt.bz2 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