From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 81469 invoked by alias); 26 Feb 2015 15:49:18 -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 81266 invoked by uid 48); 26 Feb 2015 15:49:08 -0000 From: "vekumar at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/64946] [AArch64] gcc.target/aarch64/vect-abs-compile.c - "abs" vectorization fails for char/short types Date: Thu, 26 Feb 2015 16:42:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 5.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: vekumar at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: vekumar 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: 2015-02/txt/msg02942.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64946 --- Comment #9 from vekumar at gcc dot gnu.org --- This match.pd pattern vectorizes the PR but works only with -fwrapv. (simplify ( convert (abs (convert@1 @0))) ( if (INTEGRAL_TYPE_P (type) /* We check for type compatibility between @0 and @1 below, so there's no need to check that @1/@3 are integral types. */ && INTEGRAL_TYPE_P (TREE_TYPE (@0)) && INTEGRAL_TYPE_P (TREE_TYPE (@1)) /* The precision of the type of each operand must match the precision of the mode of each operand, similarly for the result. */ && (TYPE_PRECISION (TREE_TYPE (@0)) == GET_MODE_PRECISION (TYPE_MODE (TREE_TYPE (@0)))) && (TYPE_PRECISION (TREE_TYPE (@1)) == GET_MODE_PRECISION (TYPE_MODE (TREE_TYPE (@1)))) && TYPE_PRECISION (type) == GET_MODE_PRECISION (TYPE_MODE (type)) /* The inner conversion must be a widening conversion. */ && TYPE_PRECISION (TREE_TYPE (@1)) > TYPE_PRECISION (TREE_TYPE (@0)) && ((GENERIC && (TYPE_MAIN_VARIANT (TREE_TYPE (@0)) == TYPE_MAIN_VARIANT (type))) || (GIMPLE && types_compatible_p (TREE_TYPE (@0), type)))) (if (TYPE_OVERFLOW_WRAPS (TREE_TYPE (@0))) (abs @0)))) For default cases (when no -fwrapv is given), doing ABSE_EXPR(shorttype) will invoke undefined behaviour when value is -32678. similarly for signed char min. As per Richard suggestion we need to move to a new tree code ABSU_EXPR to do this type of folding optimization.