aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJulian Brown <julian@codesourcery.com>2021-04-19 06:24:41 -0700
committerKwok Cheung Yeung <kcy@codesourcery.com>2022-06-21 14:11:37 +0100
commit4cdc152ea7155977ec2bcbe4ecff5361a66b8283 (patch)
tree5d85c1c0c4aac9a21dd31153a969883798b1bfbd /gcc
parent18dc308aeac5efb5d88bde8c0bdf0f92162fdb87 (diff)
downloadgcc-4cdc152ea7155977ec2bcbe4ecff5361a66b8283.zip
gcc-4cdc152ea7155977ec2bcbe4ecff5361a66b8283.tar.gz
gcc-4cdc152ea7155977ec2bcbe4ecff5361a66b8283.tar.bz2
[og11] Unify ARRAY_REF/INDIRECT_REF stripping code in extract_base_bit_offset
For historical reasons, it seems that extract_base_bit_offset unnecessarily used two different ways to strip ARRAY_REF/INDIRECT_REF nodes from component accesses. I verified that the two ways of performing the operation gave the same results across the whole testsuite (and several additional benchmarks). The code was like this since an earlier "mechanical" refactoring by me, first posted here: https://gcc.gnu.org/pipermail/gcc-patches/2018-November/510503.html It was never clear to me if there was an important semantic difference between the two ways of stripping the base before calling get_inner_reference, but it appears that there is not, so one can go away. 2021-06-02 Julian Brown <julian@codesourcery.com> gcc/ * gimplify.cc (extract_base_bit_offset): Unify ARRAY_REF/INDIRECT_REF stripping code in first call/subsequent call cases.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog.omp5
-rw-r--r--gcc/gimplify.cc32
2 files changed, 16 insertions, 21 deletions
diff --git a/gcc/ChangeLog.omp b/gcc/ChangeLog.omp
index bfc3bfa..cc41450 100644
--- a/gcc/ChangeLog.omp
+++ b/gcc/ChangeLog.omp
@@ -1,5 +1,10 @@
2021-06-02 Julian Brown <julian@codesourcery.com>
+ * gimplify.cc (extract_base_bit_offset): Unify ARRAY_REF/INDIRECT_REF
+ stripping code in first call/subsequent call cases.
+
+2021-06-02 Julian Brown <julian@codesourcery.com>
+
* gimplify.cc (gimplify_scan_omp_clauses): Simplify condition
for changing GOMP_MAP_ATTACH_DETACH to GOMP_MAP_ATTACH or
GOMP_MAP_DETACH.
diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc
index 4eca97d..59903ed 100644
--- a/gcc/gimplify.cc
+++ b/gcc/gimplify.cc
@@ -8824,31 +8824,21 @@ extract_base_bit_offset (tree base, tree *base_ref, poly_int64 *bitposp,
poly_offset_int poffset;
if (base_ref)
- {
- *base_ref = NULL_TREE;
-
- while (TREE_CODE (base) == ARRAY_REF)
- base = TREE_OPERAND (base, 0);
+ *base_ref = NULL_TREE;
- if (TREE_CODE (base) == INDIRECT_REF)
- base = TREE_OPERAND (base, 0);
- }
- else
+ if (TREE_CODE (base) == ARRAY_REF)
{
- if (TREE_CODE (base) == ARRAY_REF)
- {
- while (TREE_CODE (base) == ARRAY_REF)
- base = TREE_OPERAND (base, 0);
- if (TREE_CODE (base) != COMPONENT_REF
- || TREE_CODE (TREE_TYPE (base)) != ARRAY_TYPE)
- return NULL_TREE;
- }
- else if (TREE_CODE (base) == INDIRECT_REF
- && TREE_CODE (TREE_OPERAND (base, 0)) == COMPONENT_REF
- && (TREE_CODE (TREE_TYPE (TREE_OPERAND (base, 0)))
- == REFERENCE_TYPE))
+ while (TREE_CODE (base) == ARRAY_REF)
base = TREE_OPERAND (base, 0);
+ if (TREE_CODE (base) != COMPONENT_REF
+ || TREE_CODE (TREE_TYPE (base)) != ARRAY_TYPE)
+ return NULL_TREE;
}
+ else if (TREE_CODE (base) == INDIRECT_REF
+ && TREE_CODE (TREE_OPERAND (base, 0)) == COMPONENT_REF
+ && (TREE_CODE (TREE_TYPE (TREE_OPERAND (base, 0)))
+ == REFERENCE_TYPE))
+ base = TREE_OPERAND (base, 0);
base = get_inner_reference (base, &bitsize, &bitpos, &offset, &mode,
&unsignedp, &reversep, &volatilep);