From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1011) id 7C22B3858C39; Wed, 6 Oct 2021 14:52:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7C22B3858C39 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Andrew Macleod To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-4210] Use TYPE_MIN/MAX_VALUE in set_varying when possible. X-Act-Checkin: gcc X-Git-Author: Andrew MacLeod X-Git-Refname: refs/heads/master X-Git-Oldrev: 4b8ca6c6177b2bd948c1cb2a116955b942751559 X-Git-Newrev: e828f4b5898896240b2ae5d5030c539aff28ea24 Message-Id: <20211006145221.7C22B3858C39@sourceware.org> Date: Wed, 6 Oct 2021 14:52:21 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Oct 2021 14:52:21 -0000 https://gcc.gnu.org/g:e828f4b5898896240b2ae5d5030c539aff28ea24 commit r12-4210-ge828f4b5898896240b2ae5d5030c539aff28ea24 Author: Andrew MacLeod Date: Tue Sep 28 13:11:22 2021 -0400 Use TYPE_MIN/MAX_VALUE in set_varying when possible. We currently create new trees every time... which is very wasteful and time consuming. Instead, just use the TYPE_MIN/MAX_VALUE. * value-range.h (irange::set_varying): Use TYPE_MIN_VALUE and TYPE_MAX_VALUE instead of creating new trees when possible. Diff: --- gcc/value-range.h | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/gcc/value-range.h b/gcc/value-range.h index a8adc50b98e..39e8f3bcdee 100644 --- a/gcc/value-range.h +++ b/gcc/value-range.h @@ -476,10 +476,21 @@ irange::set_varying (tree type) if (INTEGRAL_TYPE_P (type)) { + // Strict enum's require varying to be not TYPE_MIN/MAX, but rather + // min_value and max_value. wide_int min = wi::min_value (TYPE_PRECISION (type), TYPE_SIGN (type)); wide_int max = wi::max_value (TYPE_PRECISION (type), TYPE_SIGN (type)); - m_base[0] = wide_int_to_tree (type, min); - m_base[1] = wide_int_to_tree (type, max); + if (wi::eq_p (max, wi::to_wide (TYPE_MAX_VALUE (type))) + && wi::eq_p (min, wi::to_wide (TYPE_MIN_VALUE (type)))) + { + m_base[0] = TYPE_MIN_VALUE (type); + m_base[1] = TYPE_MAX_VALUE (type); + } + else + { + m_base[0] = wide_int_to_tree (type, min); + m_base[1] = wide_int_to_tree (type, max); + } } else if (POINTER_TYPE_P (type)) {