From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11294 invoked by alias); 7 Jul 2019 09:43:25 -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 11286 invoked by uid 89); 7 Jul 2019 09:43:25 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-7.7 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_2,GIT_PATCH_3,KAM_ASCII_DIVIDERS,SPF_PASS autolearn=ham version=3.3.1 spammy=justify 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; Sun, 07 Jul 2019 09:43:23 +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 72E2B360 for ; Sun, 7 Jul 2019 02:43:22 -0700 (PDT) Received: from localhost (e121540-lin.manchester.arm.com [10.32.98.39]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1A7FA3F246 for ; Sun, 7 Jul 2019 02:43:21 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: Don't run DSE at -Og Date: Sun, 07 Jul 2019 09:45:00 -0000 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SW-Source: 2019-07/txt/msg00502.txt.bz2 This patch stops gimple and rtl DSE from running by default at -Og. The idea is both to improve compile time and to stop us from deleting stores that we can't track in debug info. We could rein this back in future for stores to local variables with is_gimple_reg_type, but at the moment we don't have any infrastructure for switching between binds to specific values and binds to evolving memory locations. Even then, location tracking only works for direct references to the variables, and doesn't for example help with printing dereferenced pointers (see the next patch in the series for an example). I'm also not sure that DSE is important enough for -Og to justify the compile time cost -- especially in the case of RTL DSE, which is pretty expensive. Tested on aarch64-linux-gnu and x86_64-linux-gnu. OK to install? Richard 2019-07-07 Richard Sandiford gcc/ * common.opt (Og): Change the initial value of flag_dse to 0. * opts.c (default_options_table): Move OPT_ftree_dse from OPT_LEVELS_1_PLUS to OPT_LEVELS_1_PLUS_NOT_DEBUG. Also add OPT_fdse to OPT_LEVELS_1_PLUS_NOT_DEBUG. Put the OPT_ftree_pta entry before the OPT_ftree_sra entry. * doc/invoke.texi (Og): Add -fdse and -ftree-dse to the list of flags disabled by Og. gcc/testsuite/ * c-c++-common/guality/Og-global-dse-1.c: New test. Index: gcc/common.opt =================================================================== --- gcc/common.opt 2019-07-03 20:50:45.902320943 +0100 +++ gcc/common.opt 2019-07-07 10:29:23.683336097 +0100 @@ -1955,7 +1955,7 @@ Common Var(flag_dce) Init(1) Optimizatio Use the RTL dead code elimination pass. fdse -Common Var(flag_dse) Init(1) Optimization +Common Var(flag_dse) Init(0) Optimization Use the RTL dead store elimination pass. freschedule-modulo-scheduled-loops Index: gcc/opts.c =================================================================== --- gcc/opts.c 2019-06-29 17:20:49.000000000 +0100 +++ gcc/opts.c 2019-07-07 10:29:23.691336032 +0100 @@ -466,7 +466,6 @@ static const struct default_options defa { OPT_LEVELS_1_PLUS, OPT_ftree_copy_prop, NULL, 1 }, { OPT_LEVELS_1_PLUS, OPT_ftree_dce, NULL, 1 }, { OPT_LEVELS_1_PLUS, OPT_ftree_dominator_opts, NULL, 1 }, - { OPT_LEVELS_1_PLUS, OPT_ftree_dse, NULL, 1 }, { OPT_LEVELS_1_PLUS, OPT_ftree_fre, NULL, 1 }, { OPT_LEVELS_1_PLUS, OPT_ftree_sink, NULL, 1 }, { OPT_LEVELS_1_PLUS, OPT_ftree_slsr, NULL, 1 }, @@ -477,14 +476,16 @@ static const struct default_options defa #if DELAY_SLOTS { OPT_LEVELS_1_PLUS_NOT_DEBUG, OPT_fdelayed_branch, NULL, 1 }, #endif + { OPT_LEVELS_1_PLUS_NOT_DEBUG, OPT_fdse, NULL, 1 }, { OPT_LEVELS_1_PLUS_NOT_DEBUG, OPT_fif_conversion, NULL, 1 }, { OPT_LEVELS_1_PLUS_NOT_DEBUG, OPT_fif_conversion2, NULL, 1 }, { OPT_LEVELS_1_PLUS_NOT_DEBUG, OPT_finline_functions_called_once, NULL, 1 }, { OPT_LEVELS_1_PLUS_NOT_DEBUG, OPT_fmove_loop_invariants, NULL, 1 }, { OPT_LEVELS_1_PLUS_NOT_DEBUG, OPT_fssa_phiopt, NULL, 1 }, { OPT_LEVELS_1_PLUS_NOT_DEBUG, OPT_ftree_bit_ccp, NULL, 1 }, - { OPT_LEVELS_1_PLUS_NOT_DEBUG, OPT_ftree_sra, NULL, 1 }, + { OPT_LEVELS_1_PLUS_NOT_DEBUG, OPT_ftree_dse, NULL, 1 }, { OPT_LEVELS_1_PLUS_NOT_DEBUG, OPT_ftree_pta, NULL, 1 }, + { OPT_LEVELS_1_PLUS_NOT_DEBUG, OPT_ftree_sra, NULL, 1 }, /* -O2 and -Os optimizations. */ { OPT_LEVELS_2_PLUS, OPT_fcaller_saves, NULL, 1 }, Index: gcc/doc/invoke.texi =================================================================== --- gcc/doc/invoke.texi 2019-07-03 20:50:42.346350375 +0100 +++ gcc/doc/invoke.texi 2019-07-07 10:29:23.687336062 +0100 @@ -8421,10 +8421,10 @@ no effect. Otherwise @option{-Og} enabl optimization flags except for those that may interfere with debugging: @gccoptlist{-fbranch-count-reg -fdelayed-branch @gol --fif-conversion -fif-conversion2 @gol +-fdse -fif-conversion -fif-conversion2 @gol -finline-functions-called-once @gol -fmove-loop-invariants -fssa-phiopt @gol --ftree-bit-ccp -ftree-pta -ftree-sra} +-ftree-bit-ccp -ftree-dse -ftree-pta -ftree-sra} @end table Index: gcc/testsuite/c-c++-common/guality/Og-global-dse-1.c =================================================================== --- /dev/null 2019-06-14 15:59:19.298479944 +0100 +++ gcc/testsuite/c-c++-common/guality/Og-global-dse-1.c 2019-07-07 10:29:23.691336032 +0100 @@ -0,0 +1,17 @@ +/* { dg-do run } */ +/* { dg-options "-g" } */ + +struct s { int i, j; }; +struct s gs1, gs2 = { 3, 4 }; + +void __attribute__((noipa)) consume (void) {}; + +int +main (void) +{ + gs1.i = 1; + gs1.j = 2; /* { dg-final { gdb-test . "gs1.i" "1" } } */ + gs1 = gs2; /* { dg-final { gdb-test . "gs1.j" "2" } } */ + consume (); /* { dg-final { gdb-test . "gs1.i" "3" } } */ + return 0; /* { dg-final { gdb-test . "gs1.j" "4" } } */ +}