From patchwork Fri May 7 19:02:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 1475651 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=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=I08RxFj2; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FcKbH3bhbz9t1Q for ; Sat, 8 May 2021 05:03:07 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 65F86385383B; Fri, 7 May 2021 19:03:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 65F86385383B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1620414185; bh=pGqRogG6vNVeN1EkFg/3P5/H3q/DzeZDhtMIXTP6nNY=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=I08RxFj2/T1W9tqrY1GnNvyw1vZujvUDQHMiZmKcq28ylc0xMv7w07KmRPFXosd54 jg1iJ+Ug54Xd0OBbrL9U03TfsaRrNyCbTZJMoMJxZghzeKFELvnJX5QOd2ou9RHDZF bRtvqwTyjvGiaRO4J+2vgPMO5/0AJLtwaZiDWvnY= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id C6DD53853834 for ; Fri, 7 May 2021 19:03:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org C6DD53853834 Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-270-eMPx-kJtNtqYcfcZybRgOA-1; Fri, 07 May 2021 15:03:00 -0400 X-MC-Unique: eMPx-kJtNtqYcfcZybRgOA-1 Received: by mail-qv1-f69.google.com with SMTP id b10-20020a0cf04a0000b02901bda1df3afbso7360068qvl.13 for ; Fri, 07 May 2021 12:03:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:subject:cc:message-id:date:user-agent :mime-version:content-language; bh=pGqRogG6vNVeN1EkFg/3P5/H3q/DzeZDhtMIXTP6nNY=; b=NoOITdfdB5J1NP2ov3PQfKxHbuPnWOpkiAI5vezjspUZvuD2EQS6rsbpj/iOiOJqEA tJfDorVMhrnOSjCeGN+vyRFIPD9W9rNAXHntZWuW883IMlDvTdB7vAofF4bjlDDKujSB uUrp0I3mQnZi/Sr3+WdE2Y1NMl16Iy7bNO2OQpgvvVBKkPkd2d82DssB/jBVp9f72pjC deo5p7cgnodJaBfl0Fx8D60/OwwUuGZEfBxiO0w6SxhtSUU/69hpFw2r9JTh0F6kHg+s RcEZm9OwyqyMCvpxyTWOVP7CHoNnT+6l/U4BIpsB29+KBbklO5vdwkJIEGdHDP+Woowa Tyrw== X-Gm-Message-State: AOAM533Bi1OXbJtdwPXD0uQ7NtHa76OmT8dOxJYrO+fLvLPhgTL89Y+c jDm/bW/ap9S84W1YKG+Ml1ZqL921iaaDaaBqwEwksqY0gvCJc/YCDLXQbuWKcQ/RRl2bKpQpNIO dMlKxLzDFecNlf26g3g== X-Received: by 2002:ad4:54c5:: with SMTP id j5mr11870414qvx.4.1620414179843; Fri, 07 May 2021 12:02:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJytUKQjan4ZJ7ZkALYGg0Ga37LwmVWCD8G4HjpPKLFaJ5KpQhelTfuE5aECHl+UWXC16gSegg== X-Received: by 2002:ad4:54c5:: with SMTP id j5mr11870392qvx.4.1620414179710; Fri, 07 May 2021 12:02:59 -0700 (PDT) Received: from ?IPv6:2607:fea8:a25f:fa00:6ae8:97ac:cf69:b86d? ([2607:fea8:a25f:fa00:6ae8:97ac:cf69:b86d]) by smtp.gmail.com with ESMTPSA id b7sm3871485qte.80.2021.05.07.12.02.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 07 May 2021 12:02:59 -0700 (PDT) To: gcc-patches Subject: [PATCH] Don;t over allocate switch default clauses. Message-ID: <134b0219-a891-ce78-8a6d-e3b2518223a6@redhat.com> Date: Fri, 7 May 2021 15:02:57 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.9.1 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-CA X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Andrew MacLeod via Gcc-patches From: Andrew MacLeod Reply-To: Andrew MacLeod Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" We were always allocating the 255 max ranges for the default condition.    Instead, use int_range_max to build the default range, then allocate and store only what is needed. Bootstraps on  x86_64-pc-linux-gnu with no testsuite regressions. Pushed. Andrew commit 57090307da6ff4378c84f768e2f2717095f712c1 Author: Andrew MacLeod Date: Mon Apr 26 17:50:18 2021 -0400 Don't over-allocate switch default range object. We were always allocating the 255 max ranges for the default condition. Instead, use int_range_max to build the default range, then allocate and store only what is needed. * gimple-range-edge.cc (outgoing_range::calc_switch_ranges): Compute default range into a temp and allocate only what is needed. diff --git a/gcc/gimple-range-edge.cc b/gcc/gimple-range-edge.cc index d2c7d384dff..4d4cb97bbec 100644 --- a/gcc/gimple-range-edge.cc +++ b/gcc/gimple-range-edge.cc @@ -112,8 +112,7 @@ outgoing_range::calc_switch_ranges (gswitch *sw) // // Allocate an int_range_max for the default range case, start with // varying and intersect each other case from it. - irange *default_range = m_range_allocator.allocate (255); - default_range->set_varying (type); + int_range_max default_range (type); for (x = 1; x < lim; x++) { @@ -132,7 +131,7 @@ outgoing_range::calc_switch_ranges (gswitch *sw) int_range_max def_range (low, high); range_cast (def_range, type); def_range.invert (); - default_range->intersect (def_range); + default_range.intersect (def_range); // Create/union this case with anything on else on the edge. int_range_max case_range (low, high); @@ -156,7 +155,8 @@ outgoing_range::calc_switch_ranges (gswitch *sw) irange *&slot = m_edge_table->get_or_insert (default_edge, &existed); // This should be the first call into this switch. gcc_checking_assert (!existed); - slot = default_range; + irange *dr = m_range_allocator.allocate (default_range); + slot = dr; }