From patchwork Sat Jul 15 20:47:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Monakov X-Patchwork-Id: 788975 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 3x91rW5fN4z9s75 for ; Sun, 16 Jul 2017 06:49:31 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="No7BYt2b"; dkim-atps=neutral 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:in-reply-to:references; q=dns; s= default; b=HluI+1qPihcrJhmEVmn9Qlh8kEWOsGMtUjMbJNsq5WwcOMTsv43HV XT+d3FFlvl2siEGEnexuyhAd1SUQInC5jlncQ9GHzkToUYWwez+vN7nMD6iMx5Sb QkiZwl87rtU4fNUG67Q2zssn4CWh4CEmSa4i2OCuk7LRmq1CaFCKko= 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:in-reply-to:references; s=default; bh=0zlggIsb4YC5Yln31+cbcGCmhW4=; b=No7BYt2bOzATHH5YPHn6YB5ADYzl AbBGBOT8FP0afQ5uSb0I/QgEhQaojAo14JLFIi6MmzZEexXbjyvpDTVuVJLe7FIF F3Xu6h9OA6EO33eyGQ5NudgZgY7cQvvBFqM7FWOoRJAqMRVwEfUONQd21cw+V2Zx T1uhe4sbow4/NGA= Received: (qmail 24766 invoked by alias); 15 Jul 2017 20:49:00 -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 115560 invoked by uid 89); 15 Jul 2017 20:48:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:1010 X-HELO: smtp.ispras.ru Received: from bran.ispras.ru (HELO smtp.ispras.ru) (83.149.199.196) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 15 Jul 2017 20:48:22 +0000 Received: from monopod.intra.ispras.ru (monopod.intra.ispras.ru [10.10.3.121]) by smtp.ispras.ru (Postfix) with ESMTP id B36ED60902 for ; Sat, 15 Jul 2017 23:48:17 +0300 (MSK) From: Alexander Monakov To: gcc-patches@gcc.gnu.org Subject: [PATCH 2/6] gimple-ssa-store-merging.c: fix sort_by_bitpos Date: Sat, 15 Jul 2017 23:47:45 +0300 Message-Id: <20170715204749.24398-3-amonakov@ispras.ru> In-Reply-To: <20170715204749.24398-1-amonakov@ispras.ru> References: <20170715204749.24398-1-amonakov@ispras.ru> This qsort comparator lacks anti-commutativity and can indicate A < B < A if A and B have the same bitpos. Return 0 in that case. * gimple-ssa-store-merging.c (sort_by_bitpos): Return 0 on equal bitpos. --- gcc/gimple-ssa-store-merging.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gcc/gimple-ssa-store-merging.c b/gcc/gimple-ssa-store-merging.c index 64b8351..c99960b 100644 --- a/gcc/gimple-ssa-store-merging.c +++ b/gcc/gimple-ssa-store-merging.c @@ -516,12 +516,12 @@ sort_by_bitpos (const void *x, const void *y) store_immediate_info *const *tmp = (store_immediate_info * const *) x; store_immediate_info *const *tmp2 = (store_immediate_info * const *) y; - if ((*tmp)->bitpos <= (*tmp2)->bitpos) + if ((*tmp)->bitpos < (*tmp2)->bitpos) return -1; else if ((*tmp)->bitpos > (*tmp2)->bitpos) return 1; - - gcc_unreachable (); + else + return 0; } /* Sorting function for store_immediate_info objects.