From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 112213 invoked by alias); 22 Mar 2016 13:18:00 -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 111295 invoked by uid 89); 22 Mar 2016 13:17:59 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.1 required=5.0 tests=BAYES_00,KAM_ASCII_DIVIDERS,RCVD_IN_DNSWL_NONE,SPF_PASS,T_RP_MATCHES_RCVD autolearn=no version=3.3.2 spammy=***************, Hx-languages-length:2459, cancel X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Tue, 22 Mar 2016 13:17:49 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id ED529AB22 for ; Tue, 22 Mar 2016 13:17:45 +0000 (UTC) Date: Tue, 22 Mar 2016 14:28:00 -0000 From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix PR70333 Message-ID: User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-SW-Source: 2016-03/txt/msg01245.txt.bz2 The following fixes another wide-int merge fallout by reverting back to what the code did before it (doing a wide multiplication). Bootstrapped and tested on x86_64-unknown-linux-gnu, applied. Richard. 2016-03-22 Richard Biener PR middle-end/70333 * fold-const.c (extract_muldiv_1): Properly perform multiplication in the wide type. * gcc.dg/torture/pr70333.c: New testcase. Index: gcc/fold-const.c =================================================================== *** gcc/fold-const.c (revision 234394) --- gcc/fold-const.c (working copy) *************** extract_muldiv_1 (tree t, tree c, enum t *** 6376,6393 **** bool overflow_p = false; bool overflow_mul_p; signop sign = TYPE_SIGN (ctype); ! wide_int mul = wi::mul (op1, c, sign, &overflow_mul_p); overflow_p = TREE_OVERFLOW (c) | TREE_OVERFLOW (op1); if (overflow_mul_p && ((sign == UNSIGNED && tcode != MULT_EXPR) || sign == SIGNED)) overflow_p = true; if (!overflow_p) ! { ! mul = wide_int::from (mul, TYPE_PRECISION (ctype), ! TYPE_SIGN (TREE_TYPE (op1))); ! return fold_build2 (tcode, ctype, fold_convert (ctype, op0), ! wide_int_to_tree (ctype, mul)); ! } } /* If these operations "cancel" each other, we have the main --- 6376,6392 ---- bool overflow_p = false; bool overflow_mul_p; signop sign = TYPE_SIGN (ctype); ! unsigned prec = TYPE_PRECISION (ctype); ! wide_int mul = wi::mul (wide_int::from (op1, prec, sign), ! wide_int::from (c, prec, sign), ! sign, &overflow_mul_p); overflow_p = TREE_OVERFLOW (c) | TREE_OVERFLOW (op1); if (overflow_mul_p && ((sign == UNSIGNED && tcode != MULT_EXPR) || sign == SIGNED)) overflow_p = true; if (!overflow_p) ! return fold_build2 (tcode, ctype, fold_convert (ctype, op0), ! wide_int_to_tree (ctype, mul)); } /* If these operations "cancel" each other, we have the main Index: gcc/testsuite/gcc.dg/torture/pr70333.c =================================================================== *** gcc/testsuite/gcc.dg/torture/pr70333.c (revision 0) --- gcc/testsuite/gcc.dg/torture/pr70333.c (working copy) *************** *** 0 **** --- 1,19 ---- + /* { dg-do run } */ + /* { dg-require-effective-target lp64 } */ + + unsigned long int + foo (signed char b, signed char e) + { + return ((2ULL * b) * (e * 13)) * (32 << 24); + } + + int + main () + { + if (__CHAR_BIT__ == 8 + && sizeof (int) == 4 + && sizeof (long long) == 8 + && foo (-60, 1) != 0xffffff3d00000000ULL) + __builtin_abort (); + return 0; + }