Projects
openEuler:24.03:SP1:Everything
gcc
_service:tar_scm:LoongArch-fix-signed-overflow-...
Sign Up
Log In
Username
Password
Sorry, you are not authorized to perform this action.
×
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:tar_scm:LoongArch-fix-signed-overflow-in-loongarch_emit_int_.patch of Package gcc
From 15f1e94ddd7128f407ada43fd9e4b26d4a8bba8d Mon Sep 17 00:00:00 2001 From: Xi Ruoyao <xry111@xry111.site> Date: Fri, 4 Nov 2022 01:35:25 +0800 Subject: [PATCH 026/124] 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. Signed-off-by: Peng Fan <fanpeng@loongson.cn> Signed-off-by: ticat_fp <fanpeng@loongson.cn> --- gcc/config/loongarch/loongarch.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gcc/config/loongarch/loongarch.cc b/gcc/config/loongarch/loongarch.cc index e9ba3374e..d552b162a 100644 --- a/gcc/config/loongarch/loongarch.cc +++ b/gcc/config/loongarch/loongarch.cc @@ -4177,10 +4177,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.33.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
.
浙ICP备2022010568号-2