[PATCH, GCC/ARM] Fix clear_operation_p uninitialised variable
Mihail Ionescu
mihail.ionescu@foss.arm.com
Mon Jan 20 19:42:00 GMT 2020
Hi,
This patch fixes the uninitialised 'last_regno' variable introduced in:
https://gcc.gnu.org/ml/gcc-patches/2019-12/msg01299.html
and makes the clear_operation_p code more readable.
*** gcc/ChangeLog ***
2020-01-20 Mihail-Calin Ionescu <mihail.ionescu@arm.com>
* gcc/config/arm/arm.c (clear_operation_p):
Initialise last_regno, skip first iteration
based on the first_set value and use ints instead
of the unnecessary HOST_WIDE_INTs.
Is it ok for trunk?
Regards,
Mihail
############### Attachment also inlined for ease of reply ###############
diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index 4bfceb973c47f64b2705c1ab47cc61c9f78508a9..52e1db22ac18bc281ca3deb8cf950eb3438c7e52 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -13751,13 +13751,14 @@ ldm_stm_operation_p (rtx op, bool load, machine_mode mode,
bool
clear_operation_p (rtx op, bool vfp)
{
- unsigned regno, last_regno;
+ unsigned regno;
+ unsigned last_regno = INVALID_REGNUM;
rtx elt, reg, zero;
- HOST_WIDE_INT count = XVECLEN (op, 0);
- HOST_WIDE_INT i, first_set = vfp ? 1 : 0;
+ int count = XVECLEN (op, 0);
+ int first_set = vfp ? 1 : 0;
machine_mode expected_mode = vfp ? E_SFmode : E_SImode;
- for (i = first_set; i < count; i++)
+ for (int i = first_set; i < count; i++)
{
elt = XVECEXP (op, 0, i);
@@ -13789,14 +13790,14 @@ clear_operation_p (rtx op, bool vfp)
if (vfp)
{
- if (i != 1 && regno != last_regno + 1)
+ if (i != first_set && regno != last_regno + 1)
return false;
}
else
{
if (regno == SP_REGNUM || regno == PC_REGNUM)
return false;
- if (i != 0 && regno <= last_regno)
+ if (i != first_set && regno <= last_regno)
return false;
}
-------------- next part --------------
diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index 4bfceb973c47f64b2705c1ab47cc61c9f78508a9..52e1db22ac18bc281ca3deb8cf950eb3438c7e52 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -13751,13 +13751,14 @@ ldm_stm_operation_p (rtx op, bool load, machine_mode mode,
bool
clear_operation_p (rtx op, bool vfp)
{
- unsigned regno, last_regno;
+ unsigned regno;
+ unsigned last_regno = INVALID_REGNUM;
rtx elt, reg, zero;
- HOST_WIDE_INT count = XVECLEN (op, 0);
- HOST_WIDE_INT i, first_set = vfp ? 1 : 0;
+ int count = XVECLEN (op, 0);
+ int first_set = vfp ? 1 : 0;
machine_mode expected_mode = vfp ? E_SFmode : E_SImode;
- for (i = first_set; i < count; i++)
+ for (int i = first_set; i < count; i++)
{
elt = XVECEXP (op, 0, i);
@@ -13789,14 +13790,14 @@ clear_operation_p (rtx op, bool vfp)
if (vfp)
{
- if (i != 1 && regno != last_regno + 1)
+ if (i != first_set && regno != last_regno + 1)
return false;
}
else
{
if (regno == SP_REGNUM || regno == PC_REGNUM)
return false;
- if (i != 0 && regno <= last_regno)
+ if (i != first_set && regno <= last_regno)
return false;
}
More information about the Gcc-patches
mailing list