summaryrefslogtreecommitdiff
path: root/gcc/df-scan.c
diff options
context:
space:
mode:
authorAlexandre Oliva <aoliva@redhat.com>2017-01-05 01:46:41 +0000
committerAlexandre Oliva <aoliva@gcc.gnu.org>2017-01-05 01:46:41 +0000
commit460bdc0ad8e0a1bbb5d56d5ea11595e2195fc31a (patch)
treed3f99d70c589fc7973b3d9f72ee1204b6b810884 /gcc/df-scan.c
parent4dbebf6fc367d4730d252bb6b1c669d533c13b92 (diff)
[bootstrap-O3] use unsigned type for regno in df-scan
This patch fixes a false-positive warning in df-scan, at bootstrap-O3 failed, and enables GCC to optimize out the code that leads to the warning. df_ref_create_structure was inlined into the else part of df_ref_record. Due to the condition of the corresponding if, In the else part, VRP deduced unsigned regno >= FIRST_PSEUDO_REGISTER. In df_ref_create_structure, there's another regno variable, initialized with the same expression and value as the caller's. GCC can tell as much, but this regno variable is signed. It is used, shifted right, to index a hard regset bit array within a path that tests that this signed regno < FIRST_PSEUDO_REGISTER. GCC warned about the possible out-of-range indexing into the hard regset array. It shouldn't, after all, the same regno can't possibly be both < FIRST_PSEUDO_REGISTER and >= FIRST_PSEUDO_REGISTER, can it? Well, the optimizers correctly decide it could, if it was a negative int that, when converted to unsigned, became larger than FIRST_PSEUDO_REGISTER. But GCC doesn't know regno can't be negative, so the test could not be optimize out. What's more, given the constraints, VRP correctly concluded the hard regset array would always be indexed by a value way outside the array index range. This patch changes the inlined regno to unsigned, like the caller's, so that we can now tell the conditions can't both hold, so we optimize out the path containing the would-be out-of-range array indexing. for gcc/ChangeLog * df-scan.c (df_ref_create_structure): Make regno unsigned, to match the caller. From-SVN: r244090
Diffstat (limited to 'gcc/df-scan.c')
-rw-r--r--gcc/df-scan.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/gcc/df-scan.c b/gcc/df-scan.c
index ff9d5470015..f75098c2bec 100644
--- a/gcc/df-scan.c
+++ b/gcc/df-scan.c
@@ -2483,7 +2483,7 @@ df_ref_create_structure (enum df_ref_class cl,
int ref_flags)
{
df_ref this_ref = NULL;
- int regno = REGNO (GET_CODE (reg) == SUBREG ? SUBREG_REG (reg) : reg);
+ unsigned int regno = REGNO (GET_CODE (reg) == SUBREG ? SUBREG_REG (reg) : reg);
struct df_scan_problem_data *problem_data
= (struct df_scan_problem_data *) df_scan->problem_data;