From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 128764 invoked by alias); 17 Dec 2015 09:02:06 -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 128750 invoked by uid 89); 17 Dec 2015 09:02:06 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.5 required=5.0 tests=AWL,BAYES_50,KAM_LAZY_DOMAIN_SECURITY,SPF_HELO_PASS,T_RP_MATCHES_RCVD autolearn=no version=3.3.2 spammy=cmdline, qsort, Yury, yury X-HELO: mailout1.w1.samsung.com Received: from mailout1.w1.samsung.com (HELO mailout1.w1.samsung.com) (210.118.77.11) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Thu, 17 Dec 2015 09:01:59 +0000 Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) by mailout1.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NZH00FXCVR7NG20@mailout1.w1.samsung.com> for gcc-patches@gcc.gnu.org; Thu, 17 Dec 2015 09:01:55 +0000 (GMT) Received: from eusync1.samsung.com ( [203.254.199.211]) by eucpsbgm1.samsung.com (EUCPMTA) with SMTP id EF.94.16778.30A72765; Thu, 17 Dec 2015 09:01:55 +0000 (GMT) Received: from [106.109.9.145] by eusync1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0NZH00GZMVR68870@eusync1.samsung.com>; Thu, 17 Dec 2015 09:01:55 +0000 (GMT) Subject: [PATCH 4/5] Fix intransitive comparison in compare_access_positions To: GCC Patches References: <5672787D.6040105@samsung.com> Cc: Martin Jambor From: Yury Gribov Message-id: <56727A13.6030609@samsung.com> Date: Thu, 17 Dec 2015 09:02:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 MIME-version: 1.0 In-reply-to: <5672787D.6040105@samsung.com> Content-type: multipart/mixed; boundary=------------010807080808020105090805 X-IsSubscribed: yes X-SW-Source: 2015-12/txt/msg01713.txt.bz2 This is a multi-part message in MIME format. --------------010807080808020105090805 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-length: 238 Another intransitive comparison in reload_pseudo_compare_func. Buggy scenario: 1) A and B are ints of equal presion so we return 0 2) C is REAL and thus can compare differently to A and B Cc-ing Martin who's the original author. /Yury --------------010807080808020105090805 Content-Type: text/x-patch; name="0004-Fix-intransitive-comparison-in-compare_access_positi.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename*0="0004-Fix-intransitive-comparison-in-compare_access_positi.pa"; filename*1="tch" Content-length: 2828 >From 6f3930ad81945f6b5d7aecfdda16089547a592d3 Mon Sep 17 00:00:00 2001 From: Yury Gribov Date: Sat, 12 Dec 2015 10:39:15 +0300 Subject: [PATCH 4/5] Fix intransitive comparison in compare_access_positions. 2015-12-17 Yury Gribov * tree-sra.c (compare_access_positions): Make transitive. Error message: Dec 10 23:51:43 yugr-ubuntu1404 : f951[31364]: qsort: comparison function is not transitive (comparison function 0x9aa8e0 (/home/yugr/build/gcc-4.9.3-patched-bootstrap/gcc/f951+5aa8e0), called from 0x9afeda (/home/yugr/build/gcc-4.9.3-patched-bootstrap/gcc/f951+5afeda), cmdline is "/home/yugr/build/gcc-4.9.3-patched-bootstrap/gcc/testsuite/gfortran/../../f951 /home/yugr/src/gcc-4.9.3-patched/gcc/testsuite/gfortran.fortran-torture/execute/intrinsic_set_exponent.f90 -quiet -dumpbase intrinsic_set_exponent.f90 -mtune=generic -march=x86-64 -auxbase intrinsic_set_exponent -O1 -w -fno-diagnostics-show-caret -fdiagnostics-color=never -fintrinsic-modules-path /home/yugr/install/gcc-4.9.3/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/finclude -o /tmp/ccwhVAn9.s") --- gcc/tree-sra.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c index c4fea5b..5028850 100644 --- a/gcc/tree-sra.c +++ b/gcc/tree-sra.c @@ -1432,6 +1432,13 @@ scan_function (void) return ret; } +static int +imprecise_int_type_p (const tree type) +{ + return INTEGRAL_TYPE_P (type) + && (TREE_INT_CST_LOW (TYPE_SIZE (type)) != TYPE_PRECISION (type)); +} + /* Helper of QSORT function. There are pointers to accesses in the array. An access is considered smaller than another if it has smaller offset or if the offsets are the same but is size is bigger. */ @@ -1471,16 +1478,15 @@ compare_access_positions (const void *a, const void *b) return -1; /* Put the integral type with the bigger precision first. */ else if (INTEGRAL_TYPE_P (f1->type) - && INTEGRAL_TYPE_P (f2->type)) + && INTEGRAL_TYPE_P (f2->type) + && TYPE_PRECISION (f2->type) != TYPE_PRECISION (f1->type)) return TYPE_PRECISION (f2->type) - TYPE_PRECISION (f1->type); /* Put any integral type with non-full precision last. */ - else if (INTEGRAL_TYPE_P (f1->type) - && (TREE_INT_CST_LOW (TYPE_SIZE (f1->type)) - != TYPE_PRECISION (f1->type))) + else if (imprecise_int_type_p (f1->type) + && !imprecise_int_type_p (f2->type)) return 1; - else if (INTEGRAL_TYPE_P (f2->type) - && (TREE_INT_CST_LOW (TYPE_SIZE (f2->type)) - != TYPE_PRECISION (f2->type))) + else if (!imprecise_int_type_p (f1->type) + && imprecise_int_type_p (f2->type)) return -1; /* Stabilize the sort. */ return TYPE_UID (f1->type) - TYPE_UID (f2->type); -- 1.9.1 --------------010807080808020105090805--