From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9568 invoked by alias); 24 Jul 2014 09:17:43 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 9491 invoked by uid 48); 24 Jul 2014 09:17:40 -0000 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/52478] -ftrapv calls the wrong functions in libgcc Date: Thu, 24 Jul 2014 09:17:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 4.8.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-07/txt/msg01594.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52478 --- Comment #5 from Richard Biener --- It seems that the libgcc functions for SImode are present (at least on x86_64), so sth like Index: gcc/optabs.c =================================================================== --- gcc/optabs.c (revision 212970) +++ gcc/optabs.c (working copy) @@ -5559,13 +5559,17 @@ gen_int_libfunc (optab optable, const ch enum machine_mode mode) { int maxsize = 2 * BITS_PER_WORD; + int minsize = BITS_PER_WORD; if (GET_MODE_CLASS (mode) != MODE_INT) return; if (maxsize < LONG_LONG_TYPE_SIZE) maxsize = LONG_LONG_TYPE_SIZE; - if (GET_MODE_CLASS (mode) != MODE_INT - || GET_MODE_BITSIZE (mode) < BITS_PER_WORD + if (minsize > INT_TYPE_SIZE + && (trapv_binoptab_p (optable) + || trapv_unoptab_p (optable))) + minsize = INT_TYPE_SIZE; + if (GET_MODE_BITSIZE (mode) < minsize || GET_MODE_BITSIZE (mode) > maxsize) return; gen_libfunc (optable, opname, suffix, mode); Index: gcc/expr.c =================================================================== --- gcc/expr.c (revision 212970) +++ gcc/expr.c (working copy) @@ -9212,7 +9212,9 @@ expand_expr_real_2 (sepops ops, rtx targ if (modifier == EXPAND_STACK_PARM) target = 0; temp = expand_binop (mode, this_optab, op0, op1, target, - unsignedp, OPTAB_LIB_WIDEN); + unsignedp, + trapv_binoptab_p (this_optab) + ? OPTAB_LIB : OPTAB_LIB_WIDEN); gcc_assert (temp); /* Bitwise operations do not need bitfield reduction as we expect their operands being properly truncated. */ makes the testcase pass.