From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1011) id 6429138582AE; Thu, 22 Sep 2022 18:49:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6429138582AE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1663872552; bh=KeBIRqUg52e6USOxzvkXCKl4K+nyx39CvvMgLioDrLU=; h=From:To:Subject:Date:From; b=LHEUSHG9Wi/UF/P4MF7h5xh2uEd3v8nuoHmPL07454YuHpf/ITyqFCdiYmVoKwjgI bhfpIXsdCMDL4PkEvz008qlwzoORxZDnPEAhJOZ2j1NFqlWAvGCiuab7XSxR12yOLp gwdSYJZCiY3VWHWLZifieXhL4QA+EQR5ISfXENgI= 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 r13-2786] Fix calc_op1 for undefined op2_range. X-Act-Checkin: gcc X-Git-Author: Andrew MacLeod X-Git-Refname: refs/heads/master X-Git-Oldrev: 51ce06385bf259a092f830f1a6dcc4b98757919e X-Git-Newrev: a7a6649f4e7c459a95dee1600554ad06aaeb1cf6 Message-Id: <20220922184912.6429138582AE@sourceware.org> Date: Thu, 22 Sep 2022 18:49:12 +0000 (GMT) List-Id: https://gcc.gnu.org/g:a7a6649f4e7c459a95dee1600554ad06aaeb1cf6 commit r13-2786-ga7a6649f4e7c459a95dee1600554ad06aaeb1cf6 Author: Andrew MacLeod Date: Thu Sep 22 10:27:17 2022 -0400 Fix calc_op1 for undefined op2_range. Unary operations pass the type of operand 1 into op1_range. If that range is undefined, the routine blindly picks the type of operand 2, which in the case of a unary op, does not exist and traps. * gimple-range-op.cc (gimple_range_op_handler::calc_op1): Use operand 1 for second range if there is no operand 2. Diff: --- gcc/gimple-range-op.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gcc/gimple-range-op.cc b/gcc/gimple-range-op.cc index f03125a0fc5..ab5b389449d 100644 --- a/gcc/gimple-range-op.cc +++ b/gcc/gimple-range-op.cc @@ -208,10 +208,14 @@ gimple_range_op_handler::calc_op1 (vrange &r, const vrange &lhs_range, // If op2 is undefined, solve as if it is varying. if (op2_range.undefined_p ()) { - // This is sometimes invoked on single operand stmts. if (gimple_num_ops (m_stmt) < 3) return false; - tree op2_type = TREE_TYPE (operand2 ()); + tree op2_type; + // This is sometimes invoked on single operand stmts. + if (operand2 ()) + op2_type = TREE_TYPE (operand2 ()); + else + op2_type = TREE_TYPE (operand1 ()); Value_Range trange (op2_type); trange.set_varying (op2_type); return op1_range (r, type, lhs_range, trange);