From patchwork Tue Dec 31 15:33:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 1216777 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-516552-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="l6p+8ndg"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47nJGx1Kltz9sPh for ; Wed, 1 Jan 2020 02:33:27 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type; q=dns; s= default; b=TD6aM9wyaSe1muk7QcfWgoz/wUN0u8OOZQ0HWBOYo5D19yThLZxtq zfbv7PSnqBWui/tF+KvTurcMvQiTrUvraoEU/Wbk7aqNpd7q1TIlxA8gl9ok6M1i HqqT1xAZg7LSRWjsRevlvpJFaY5cL1lPgvyaho+IWKa+iKhbXT3Myk= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type; s= default; bh=iC5MWn4KFOjkbgW3POyVLdZhd1s=; b=l6p+8ndg3lyR6Rv7bvAG PnrLC0gGDhAWll6WXZhDG8ljdTqW0PnuslExgNgacv/3BZqlYrHHOp+hglsVCQZN l953FYkYY7p4tvvu5tt/oJHuQ/13+jyG02dgYeXFHmIA8JMrfNUs68cjrn584EHB 3Ky6ASU5jfsd7QQMxpQwwPg= Received: (qmail 57049 invoked by alias); 31 Dec 2019 15:33:19 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 57039 invoked by uid 89); 31 Dec 2019 15:33:19 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-9.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy= X-HELO: foss.arm.com Received: from foss.arm.com (HELO foss.arm.com) (217.140.110.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 31 Dec 2019 15:33:18 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A56F931B for ; Tue, 31 Dec 2019 07:33:16 -0800 (PST) Received: from localhost (e121540-lin.manchester.arm.com [10.32.98.126]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 4E16F3F68F for ; Tue, 31 Dec 2019 07:33:16 -0800 (PST) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: [committed] Fix EXTRACT_LAST_REDUCTION segfault Date: Tue, 31 Dec 2019 15:33:15 +0000 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 X-IsSubscribed: yes This code: /* Make sure we don't accidentally use the old condition. */ cond_expr = NULL_TREE; was misplaced, since it triggered even when we needed to force the original unmodified cond_expr into a mask temporary and then invert it. Tested on aarch64-linux-gnu and applied as obvious. Richard 2019-12-31 Richard Sandiford gcc/ * tree-vect-stmts.c (vectorizable_condition): Only nullify cond_expr if we've created a new condition. Don't nullify it if we've decided to keep it and then invert the result. gcc/testsuite/ * gcc.dg/vect/vect-cond-reduc-6.c: New test. Index: gcc/tree-vect-stmts.c =================================================================== --- gcc/tree-vect-stmts.c 2019-12-29 09:27:46.623861776 +0000 +++ gcc/tree-vect-stmts.c 2019-12-31 15:31:37.226253333 +0000 @@ -10033,10 +10033,12 @@ vectorizable_condition (stmt_vec_info st if (new_code == ERROR_MARK) must_invert_cmp_result = true; else - cond_code = new_code; + { + cond_code = new_code; + /* Make sure we don't accidentally use the old condition. */ + cond_expr = NULL_TREE; + } } - /* Make sure we don't accidentally use the old condition. */ - cond_expr = NULL_TREE; std::swap (then_clause, else_clause); } Index: gcc/testsuite/gcc.dg/vect/vect-cond-reduc-6.c =================================================================== --- /dev/null 2019-09-17 11:41:18.176664108 +0100 +++ gcc/testsuite/gcc.dg/vect/vect-cond-reduc-6.c 2019-12-31 15:31:37.226253333 +0000 @@ -0,0 +1,10 @@ +/* { dg-do compile } */ + +int +f (int *y) +{ + int res = 0; + for (int i = 0; i < 100; ++i) + res = (y[i] & 1) == 0 && (y[i] < 10) ? res : 1; + return res; +}