From a1c138325c69c051fa9eb04d350ca2967a6480f7 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Mon, 8 Aug 2016 21:35:11 +0930 Subject: [PATCH] [RS6000] TOC refs generated during reload The generic reload fix for pr72771 exposed a problem with recognizing -mcmodel=medium/large TOC references generated during reload. PR target/72771 * config/rs6000/rs6000.c (toc_relative_expr_p): Allow (lo_sum (high)) toc refs created during reload. Update function comment. From-SVN: r239240 --- gcc/ChangeLog | 6 ++++++ gcc/config/rs6000/rs6000.c | 20 ++++++++++++-------- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 083b6136639..66e4049915b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2016-08-08 Alan Modra + + PR target/72771 + * config/rs6000/rs6000.c (toc_relative_expr_p): Allow (lo_sum (high)) + toc refs created during reload. Update function comment. + 2016-08-08 Alan Modra PR target/72802 diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index c59d07ac899..5aa056cb4c8 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -7937,8 +7937,8 @@ constant_pool_expr_p (rtx op) static const_rtx tocrel_base, tocrel_offset; /* Return true if OP is a toc pointer relative address (the output - of create_TOC_reference). If STRICT, do not match high part or - non-split -mcmodel=large/medium toc pointer relative addresses. */ + of create_TOC_reference). If STRICT, do not match non-split + -mcmodel=large/medium toc pointer relative addresses. */ bool toc_relative_expr_p (const_rtx op, bool strict) @@ -7948,13 +7948,17 @@ toc_relative_expr_p (const_rtx op, bool strict) if (TARGET_CMODEL != CMODEL_SMALL) { - /* Only match the low part. */ - if (GET_CODE (op) == LO_SUM - && REG_P (XEXP (op, 0)) - && INT_REG_OK_FOR_BASE_P (XEXP (op, 0), strict)) - op = XEXP (op, 1); - else if (strict) + /* When strict ensure we have everything tidy. */ + if (strict + && !(GET_CODE (op) == LO_SUM + && REG_P (XEXP (op, 0)) + && INT_REG_OK_FOR_BASE_P (XEXP (op, 0), strict))) return false; + + /* When not strict, allow non-split TOC addresses and also allow + (lo_sum (high ..)) TOC addresses created during reload. */ + if (GET_CODE (op) == LO_SUM) + op = XEXP (op, 1); } tocrel_base = op; -- 2.30.2