From 06c1602ae4d1ff3270aa12ba6f010cd51302fe91 Mon Sep 17 00:00:00 2001 From: Segher Boessenkool Date: Sun, 24 Mar 2019 21:26:53 +0100 Subject: [PATCH] rs6000: Make CSE'ing __tls_get_addr calls possible CSE does not consider calls, not even const calls. This patch puts a REG_EQUAL note on the pseudo we assign the __tls_get_addr result to, so that those pseudos can be CSE'd and the extra calls deleted as dead code. CSE should really handle const calls directly, but it is stage 4. * config/rs6000/rs6000.c (rs6000_legitimize_tls_address): Add REG_EQUAL notes for the result of the __tls_get_addr calls. * config/rs6000/rs6000.md (unspec UNSPEC_TLS_GET_ADDR): New. From-SVN: r269902 --- gcc/ChangeLog | 8 +++++++- gcc/config/rs6000/rs6000.c | 10 ++++++++++ gcc/config/rs6000/rs6000.md | 1 + 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 85ec6be48e1..8ce3d7cd337 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,4 +1,10 @@ -2019-03-26 Jeff Law +2019-03-24 Segher Boessenkool + + * config/rs6000/rs6000.c (rs6000_legitimize_tls_address): Add REG_EQUAL + notes for the result of the __tls_get_addr calls. + * config/rs6000/rs6000.md (unspec UNSPEC_TLS_GET_ADDR): New. + +2019-03-24 Jeff Law * config/bfin/bfin.md (movpdi): Fix length for alternative 1. diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 734c3860ffe..06ce2892bf9 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -8785,6 +8785,11 @@ rs6000_legitimize_tls_address (rtx addr, enum tls_model model) else emit_library_call_value (tga, dest, LCT_CONST, Pmode); global_tlsarg = NULL_RTX; + + /* Make a note so that the result of this call can be CSEd. */ + rtvec vec = gen_rtvec (1, copy_rtx (arg)); + rtx uns = gen_rtx_UNSPEC (Pmode, vec, UNSPEC_TLS_GET_ADDR); + set_unique_reg_note (get_last_insn (), REG_EQUAL, uns); } else if (model == TLS_MODEL_LOCAL_DYNAMIC) { @@ -8803,6 +8808,11 @@ rs6000_legitimize_tls_address (rtx addr, enum tls_model model) emit_library_call_value (tga, tmp1, LCT_CONST, Pmode); global_tlsarg = NULL_RTX; + /* Make a note so that the result of this call can be CSEd. */ + rtvec vec = gen_rtvec (1, copy_rtx (arg)); + rtx uns = gen_rtx_UNSPEC (Pmode, vec, UNSPEC_TLS_GET_ADDR); + set_unique_reg_note (get_last_insn (), REG_EQUAL, uns); + if (rs6000_tls_size == 16) { if (TARGET_64BIT) diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md index 297b884f648..b8dd85905f3 100644 --- a/gcc/config/rs6000/rs6000.md +++ b/gcc/config/rs6000/rs6000.md @@ -79,6 +79,7 @@ UNSPEC_MPIC_CORRECT ; macho_correct_pic UNSPEC_TLSGD UNSPEC_TLSLD + UNSPEC_TLS_GET_ADDR UNSPEC_MOVESI_FROM_CR UNSPEC_MOVESI_TO_CR UNSPEC_TLSDTPREL -- 2.30.2