From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 52204 invoked by alias); 11 Nov 2018 23:11:52 -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 52192 invoked by uid 89); 11 Nov 2018 23:11:52 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.5 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_LAZY_DOMAIN_SECURITY autolearn=ham version=3.3.2 spammy=Early, H*Ad:D*linaro.org, codes, rematerialize X-HELO: gcc1-power7.osuosl.org Received: from gcc1-power7.osuosl.org (HELO gcc1-power7.osuosl.org) (140.211.15.137) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 11 Nov 2018 23:11:50 +0000 Received: by gcc1-power7.osuosl.org (Postfix, from userid 10019) id 2B0231240891; Sun, 11 Nov 2018 23:11:48 +0000 (UTC) From: Segher Boessenkool To: gcc-patches@gcc.gnu.org Cc: Segher Boessenkool , Richard Sandiford Subject: [RFC PATCH] rs6000: Early remat for CR fields Date: Sun, 11 Nov 2018 23:11:00 -0000 Message-Id: X-IsSubscribed: yes X-SW-Source: 2018-11/txt/msg00876.txt.bz2 This implements early remat for condition codes, for rs6000. Saving and restoring the CR register is pretty expensive, so we want to avoid doing it. It is an RFC for two reasons. Firstly, I needed to delete the NUM_POLY_INT_COEFFS > 1 check from generic code, since that has nothing to do with early remat, it's just for Arm SVE. This should be moved to the aarch64 hook implementation? Secondly, it makes almost all (or all?) asan tests fail. I do not know why; everything else works fine. This needs to be investigated, Early remat does not handle instructions that set a condition reg as well as another (general purpose) register. It could, by rematerializing the instruction as just the comparison. I don't know how much this would help (it would allow rematerializing Power "dot" instructions, which are pretty frequent). Segher --- gcc/config/rs6000/rs6000.c | 17 +++++++++++++++++ gcc/early-remat.c | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index c60e1b2..3411570 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -1589,6 +1589,9 @@ static const struct attribute_spec rs6000_attribute_table[] = #undef TARGET_SET_UP_BY_PROLOGUE #define TARGET_SET_UP_BY_PROLOGUE rs6000_set_up_by_prologue +#undef TARGET_SELECT_EARLY_REMAT_MODES +#define TARGET_SELECT_EARLY_REMAT_MODES rs6000_select_early_remat_modes + #undef TARGET_SHRINK_WRAP_GET_SEPARATE_COMPONENTS #define TARGET_SHRINK_WRAP_GET_SEPARATE_COMPONENTS rs6000_get_separate_components #undef TARGET_SHRINK_WRAP_COMPONENTS_FOR_BB @@ -26031,6 +26034,20 @@ rs6000_global_entry_point_needed_p (void) return cfun->machine->r2_setup_needed; } +/* Implement TARGET_SELECT_EARLY_REMAT_MODES. */ + +static void +rs6000_select_early_remat_modes (sbitmap modes) +{ + /* We want to rematerialize all condition codes. */ + for (int i = 0; i < NUM_MACHINE_MODES; ++i) + { + machine_mode mode = (machine_mode) i; + if (GET_MODE_CLASS (mode) == MODE_CC) + bitmap_set_bit (modes, i); + } +} + /* Implement TARGET_SHRINK_WRAP_GET_SEPARATE_COMPONENTS. */ static sbitmap rs6000_get_separate_components (void) diff --git a/gcc/early-remat.c b/gcc/early-remat.c index 776b2d0..b969e28 100644 --- a/gcc/early-remat.c +++ b/gcc/early-remat.c @@ -2588,7 +2588,7 @@ public: /* opt_pass methods: */ virtual bool gate (function *) { - return optimize > 1 && NUM_POLY_INT_COEFFS > 1; + return optimize > 1; } virtual unsigned int execute (function *f) -- 1.8.3.1