From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A06B43858C5F; Sat, 6 Apr 2024 22:46:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A06B43858C5F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1712443578; bh=svh2f/X0KdIw3/TawRu4O3ro9lFmwZevmUzb4xIF4w4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Iv4hheUL0+13KxZ9hFGAwbHnsYnLqjNR2XJJf/OBXoFUJqQltmuXp+kalRVdKb7m2 nQkJRNm5GswYjdHefIVYSomJi5aicg4RvgDa06q1W7s8s5fmQ7fwp+Zbrdy1D0DStv 8lH6Xd4rvJq0xckHAL1X9Nn5ryYsWkkOveY8rYOU= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug modula2/114617] gm2 is unable to resolve const expression using relative operators ICE Date: Sat, 06 Apr 2024 22:46:15 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: modula2 X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: gaius at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D114617 --- Comment #4 from GCC Commits --- The master branch has been updated by Gaius Mulley : https://gcc.gnu.org/g:4e3c8257304c55f2ebfb24bd6de3236bda0f054e commit r14-9823-g4e3c8257304c55f2ebfb24bd6de3236bda0f054e Author: Gaius Mulley Date: Sat Apr 6 23:45:35 2024 +0100 PR modula2/114617 gm2 unable to resolve const expressions using relop I= CE This patch allows cc1gm2 to resolve constant expressions which use relative operators. Previous to the patch the result of a relop was stored in a temporary variable set by an if then else quadruple sequence. This patch marks a const expression in the quadruples and then reduces this sequence of quadruples into a single assignment to an internal constant. gcc/m2/ChangeLog: PR modula2/114617 * gm2-compiler/M2GenGCC.mod (CodeStatememt): Add quad trace. (ResolveConstantExpressions): Add parameter p to FoldIfLess, FoldIfGre, FoldIfLessEqu, FoldIfGreEqu, FoldIfEqu, FoldIfNotEqu, FoldIfIn and FoldIfNotIn. (CodeInline): Add constExpr variable and pass it to GetQuadOtok. (CodeReturnValue): Ditto. (CodeParam): Ditto. (FoldStringLength): Ditto. (FoldStringConvertM2nul): Ditto. (FoldStringConvertCnul): Ditto. (DeclaredOperandsBecomes): Ditto. (TypeCheckBecomes): Ditto. (PerformFoldBecomes): Ditto. (CodeBecomes): Ditto. (CheckElementSetTypes): Ditto. (CodeBinarySet): Ditto. (PerformCodeIfLess): Ditto. (PerformCodeIfGre): Ditto. (PerformCodeIfLessEqu): Ditto. (PerformCodeIfGreEqu): Ditto. (PerformCodeIfEqu): Ditto. (PerformCodeIfNotEqu): Ditto. (IsValidExpressionRelOp): Ditto. (PerformCodeIfIn): Ditto. (PerformCodeIfNotIn): Ditto. (CodeXIndr): Ditto. (QuadCondition): New procedure function. (IsBooleanRelOpPattern): Ditto. (FoldBooleanRelopPattern): Ditto. (FoldIfGre): Check for boolean relop constant expression and add parameter p. (FoldIfLessEqu): Ditto. (FoldIfIn): Ditto. (FoldIfEqu): Ditto. (FoldIfNotIn): Ditto. (FoldIfGreEqu): New procedure. (FoldIfNotEqu): Ditto. * gm2-compiler/M2Optimize.mod (ReduceBranch): Add constExpr variable and pass it to GetQuadOtok. * gm2-compiler/M2Quads.def (IsBecomes): New procedure function. (IsDummy): Ditto. (IsQuadConstExpr): Ditto. (SetQuadConstExpr): Ditto. (GetQuadDest): New procedure. (GetQuadOp1): New procedure. (GetQuadOp2): New procedure. (GetQuadOp3): New procedure. (GetQuadOtok): New procedure. (GetQuadOTypetok): New procedure. (PutQuadOtok): New procedure. (IsInConstParameters): New procedure function. * gm2-compiler/M2Quads.mod (IsBecomes): New procedure function. (IsDummy): Ditto. (IsQuadConstExpr): Ditto. (SetQuadConstExpr): Ditto. (GetQuadDest): New procedure. (GetQuadOp1): New procedure. (GetQuadOp2): New procedure. (GetQuadOp3): New procedure. (GetQuadOtok): New procedure. (GetQuadOTypetok): New procedure. (PutQuadOtok): New procedure. (IsInConstParameters): New procedure function. (ConstStack): Remove to ... (ConstExprStack): ... this. (ConstParamStack): New variable and initialize. (QuadFrame): New field ConstExpr. (GetQuadOtok): Add parameter constExpr and assign. (PutQuadOtok): Add constExpr parameter and assign. (PutQuadOType): Ditto. (GetQuadOTypetok): Ditto. (EraseQuad): Assign ConstExpr to FALSE. (FoldSubrange): Set ConstExpr to FALSE in BecomesOp. (PushInConstParameters): New procedure. (PopInConstParameters): New procedure. (IsInConstParameters): New procedure function. * gm2-compiler/M2SymInit.mod (IssueConditional): Add constExpr boolean variable. (CheckReadBeforeInitQuad): Ditto. (trashParam): Ditto. * gm2-compiler/P3Build.bnf (ConstExpression): Call PushInConstExpression and PopInConstExpression. (ConstSetOrQualidentOrFunction): Call PushInConstParameters and PopInConstParameters. * gm2-compiler/PCBuild.bnf (ConstExpression): Call PushInConstExpression and PopInConstExpression. * gm2-compiler/PHBuild.bnf: Ditto * gm2-gcc/m2expr.cc (m2expr_BuildCondIfExpression): New function. * gm2-gcc/m2expr.def (BuildCondIfExpression): New prototype. * gm2-gcc/m2expr.h (m2expr_BuildCondIfExpression): New function. gcc/testsuite/ChangeLog: PR modula2/114617 * gm2/iso/const/pass/iso-const-pass.exp: New test. Signed-off-by: Gaius Mulley =