diff options
author | Andre Vieira <andre.simoesdiasvieira@arm.com> | 2022-02-21 09:41:53 +0000 |
---|---|---|
committer | Andre Vieira <andre.simoesdiasvieira@arm.com> | 2022-02-21 09:41:53 +0000 |
commit | d34cdec56728ddbdfacabd9f80598b17d1c6ff54 (patch) | |
tree | 6cf9bcc5d14258f3e46b152632d8ce77059f8214 | |
parent | e01530ec1e33f7df9c2acd0489d6d1f766cb1921 (diff) | |
download | gcc-d34cdec56728ddbdfacabd9f80598b17d1c6ff54.zip gcc-d34cdec56728ddbdfacabd9f80598b17d1c6ff54.tar.gz gcc-d34cdec56728ddbdfacabd9f80598b17d1c6ff54.tar.bz2 |
rtl-optimization/104498: Fix comparing symbol reference
gcc/ChangeLog:
PR rtl-optimization/104498
* alias.cc (compare_base_symbol_refs): Correct distance computation
when swapping x and y.
-rw-r--r-- | gcc/alias.cc | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/gcc/alias.cc b/gcc/alias.cc index 3fd71cf..8c08452 100644 --- a/gcc/alias.cc +++ b/gcc/alias.cc @@ -2195,6 +2195,7 @@ compare_base_symbol_refs (const_rtx x_base, const_rtx y_base, tree x_decl = SYMBOL_REF_DECL (x_base); tree y_decl = SYMBOL_REF_DECL (y_base); bool binds_def = true; + bool swap = false; if (XSTR (x_base, 0) == XSTR (y_base, 0)) return 1; @@ -2204,6 +2205,7 @@ compare_base_symbol_refs (const_rtx x_base, const_rtx y_base, { if (!x_decl) { + swap = true; std::swap (x_decl, y_decl); std::swap (x_base, y_base); } @@ -2238,8 +2240,8 @@ compare_base_symbol_refs (const_rtx x_base, const_rtx y_base, if (SYMBOL_REF_BLOCK (x_base) != SYMBOL_REF_BLOCK (y_base)) return 0; if (distance) - *distance += (SYMBOL_REF_BLOCK_OFFSET (y_base) - - SYMBOL_REF_BLOCK_OFFSET (x_base)); + *distance += (swap ? -1 : 1) * (SYMBOL_REF_BLOCK_OFFSET (y_base) + - SYMBOL_REF_BLOCK_OFFSET (x_base)); return binds_def ? 1 : -1; } /* Either the symbols are equal (via aliasing) or they refer to |