From patchwork Fri Oct 4 14:25:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Law X-Patchwork-Id: 1171863 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-510260-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="CD1AFpmV"; 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 46lBxz223gz9sPq for ; Sat, 5 Oct 2019 00:26:12 +1000 (AEST) 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:message-id:date:mime-version:content-type; q=dns; s= default; b=LGMeahCLNBjiCPU+9NsAUP4uzvVtzNR1rEza1Hhdm4eE7Ma4gi8aB bYMAV1yDqNNWFnT4TkEBZvLeHrTYTyyd6BniEqdHswPccbKugcfCAvfJFE/rQyLI eXYILH0UczJf7//Hf7/87nEKlLUrDJq13/JZemvoxiOK2aUF4zuJZg= 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:message-id:date:mime-version:content-type; s= default; bh=NMFCjJ/mQDKNSATl7kvbgoUBg+E=; b=CD1AFpmVvFAIm4Zn1xUs 3AatgkLPXdF7vywK4XL8MQIHNyMEvj5//Ik+sTbUjaOTaEUNANlT86DPhzUlsIV5 rZ4/BC5l7aLXkk9sg+8YZ6j68UY5Pc0jcqblFWYl+T4MQCYcRy6L7dnDHADeDJB4 tuPyjhgsNYKTJ0RDnVKOPnM= Received: (qmail 108376 invoked by alias); 4 Oct 2019 14:26:04 -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 108368 invoked by uid 89); 4 Oct 2019 14:26:04 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-14.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=ranger X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 04 Oct 2019 14:26:02 +0000 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C7B1418C429D for ; Fri, 4 Oct 2019 14:26:01 +0000 (UTC) Received: from localhost.localdomain (ovpn-112-68.rdu2.redhat.com [10.10.112.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id B8D32614C7 for ; Fri, 4 Oct 2019 14:26:00 +0000 (UTC) From: Jeff Law Openpgp: preference=signencrypt To: gcc-patches Subject: [committed] Avoid ranger self-test failures for 16bit integer targets Message-ID: <683397c9-b308-b29f-934c-2b1e1b455ec4@redhat.com> Date: Fri, 4 Oct 2019 08:25:59 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 X-IsSubscribed: yes My tester started spitting out failures for targets with 16bit integers after the introduction of range-ops. It turns out two of the selftests in range_tests assume that shorts and ints are different sizes. The first creates a range with [0, MAXINT] bounds, converts it to a short and verifies that the resultant range is [MINSHORT, MAXSHORT]. That's the proper behavior for a narrowing conversion. But when ints and shorts have the same size the conversion is a nop. The second test creates a nonzero int range, then converts it to a short and again tests the resultant range. In this case as well when ints and shorts have different sizes the result should be [MINSHORT, MAXSHORT]. But when ints and shorts have the same size the resultant range is unchanged. This patch makes both tests conditional on the precision of int being larger than the precision of a short. The net result is the 16bit integer targets no longer fail the selftests allowing them to proceed normally through the target library builds and gcc testsuite runs. Bootstrapped and regression tested on x86_64 and others. We've still got guality regressions relative to the last good run, but those are unrelated to this change (At least some are Jan's. Others still need analysis). Installing on the trunk momentarily. Jeff * range-op.cc (range_tests): Avoid two tests when ints and shorts are the same size. diff --git a/gcc/range-op.cc b/gcc/range-op.cc index b538b00459a..a67cdbf77ba 100644 --- a/gcc/range-op.cc +++ b/gcc/range-op.cc @@ -2909,10 +2909,14 @@ range_tests () // If a range is in any way outside of the range for the converted // to range, default to the range for the new type. - r1 = value_range_base (integer_zero_node, maxint); - range_cast (r1, short_integer_type_node); - ASSERT_TRUE (r1.lower_bound () == wi::to_wide (minshort) - && r1.upper_bound() == wi::to_wide (maxshort)); + if (TYPE_PRECISION (TREE_TYPE (maxint)) + > TYPE_PRECISION (short_integer_type_node)) + { + r1 = value_range_base (integer_zero_node, maxint); + range_cast (r1, short_integer_type_node); + ASSERT_TRUE (r1.lower_bound () == wi::to_wide (minshort) + && r1.upper_bound() == wi::to_wide (maxshort)); + } // (unsigned char)[-5,-1] => [251,255]. r0 = rold = value_range_base (SCHAR (-5), SCHAR (-1)); @@ -3019,11 +3023,15 @@ range_tests () // "NOT 0 at signed 32-bits" ==> [-MIN_32,-1][1, +MAX_32]. This is // is outside of the range of a smaller range, return the full // smaller range. - r0 = range_nonzero (integer_type_node); - range_cast (r0, short_integer_type_node); - r1 = value_range_base (TYPE_MIN_VALUE (short_integer_type_node), - TYPE_MAX_VALUE (short_integer_type_node)); - ASSERT_TRUE (r0 == r1); + if (TYPE_PRECISION (integer_type_node) + > TYPE_PRECISION (short_integer_type_node)) + { + r0 = range_nonzero (integer_type_node); + range_cast (r0, short_integer_type_node); + r1 = value_range_base (TYPE_MIN_VALUE (short_integer_type_node), + TYPE_MAX_VALUE (short_integer_type_node)); + ASSERT_TRUE (r0 == r1); + } // Casting NONZERO from a narrower signed to a wider signed. //