Projects
openEuler:22.03:LTS:LoongArch
gcc
_service:tar_scm_kernel_repo:0043-LoongArch-fix...
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:tar_scm_kernel_repo:0043-LoongArch-fix-signed-overflow-in-loongarch_emit_int_.patch of Package gcc
From cbebeb6af741b628e9714240fdcebca58c61e56e Mon Sep 17 00:00:00 2001 From: XingLi <lixing@loongson.cn> Date: Thu, 27 Jul 2023 09:16:55 +0800 Subject: [PATCH 2/2] LoongArch: fix signed overflow in loongarch_emit_int_compare Signed overflow is an undefined behavior, so we need to prevent it from happening, instead of "checking" the result. gcc/ChangeLog: * config/loongarch/loongarch.cc (loongarch_emit_int_compare): Avoid signed overflow. From: Xi Ruoyao <xry111@xry111.site> --- gcc/config/loongarch/loongarch.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gcc/config/loongarch/loongarch.c b/gcc/config/loongarch/loongarch.c index 4ddcaa446..95b4ed5d9 100644 --- a/gcc/config/loongarch/loongarch.c +++ b/gcc/config/loongarch/loongarch.c @@ -4174,10 +4174,13 @@ loongarch_emit_int_compare (enum rtx_code *code, rtx *op0, rtx *op1) if (!increment && !decrement) continue; + if ((increment && rhs == HOST_WIDE_INT_MAX) + || (decrement && rhs == HOST_WIDE_INT_MIN)) + break; + new_rhs = rhs + (increment ? 1 : -1); if (loongarch_integer_cost (new_rhs) - < loongarch_integer_cost (rhs) - && (rhs < 0) == (new_rhs < 0)) + < loongarch_integer_cost (rhs)) { *op1 = GEN_INT (new_rhs); *code = mag_comparisons[i][increment]; -- 2.27.0
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.