From b807e627309cb88537a127946c22abf31d358c51 Mon Sep 17 00:00:00 2001 From: Martin Jambor Date: Fri, 24 Jun 2011 15:27:44 +0200 Subject: [PATCH] re PR tree-optimization/49516 (SRA generates memory references into its replacements) 2011-06-24 Martin Jambor PR tree-optimizations/49516 * tree-sra.c (sra_modify_assign): Choose the safe path for aggregate copies if we also did scalar replacements. * testsuite/g++.dg/tree-ssa/pr49516.C: New test. From-SVN: r175376 --- gcc/ChangeLog | 6 ++ gcc/testsuite/ChangeLog | 5 ++ gcc/testsuite/g++.dg/tree-ssa/pr49516.C | 86 +++++++++++++++++++++++++ gcc/tree-sra.c | 3 +- 4 files changed, 99 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/tree-ssa/pr49516.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7eb82253333..fa88db30b28 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2011-06-24 Martin Jambor + + PR tree-optimizations/49516 + * tree-sra.c (sra_modify_assign): Choose the safe path for + aggregate copies if we also did scalar replacements. + 2011-06-24 Ramana Radhakrishnan PR target/49335 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index bab71b3f32a..c0f297671da 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-06-24 Martin Jambor + + PR tree-optimizations/49516 + * g++.dg/tree-ssa/pr49516.C: New test. + 2011-06-23 Jason Merrill PR c++/35255 diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr49516.C b/gcc/testsuite/g++.dg/tree-ssa/pr49516.C new file mode 100644 index 00000000000..2c6fd0496fc --- /dev/null +++ b/gcc/testsuite/g++.dg/tree-ssa/pr49516.C @@ -0,0 +1,86 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +extern "C" void abort (void); + +typedef int int32; +typedef unsigned int uint32; +typedef unsigned long long uint64; +typedef short int16; + +class Tp { + public: + Tp(int, const int segment, const int index) __attribute__((noinline)); + + inline bool operator==(const Tp& other) const; + inline bool operator!=(const Tp& other) const; + int GetType() const { return type_; } + int GetSegment() const { return segment_; } + int GetIndex() const { return index_; } + private: + inline static bool IsValidSegment(const int segment); + static const int kSegmentBits = 28; + static const int kTypeBits = 4; + static const int kMaxSegment = (1 << kSegmentBits) - 1; + + union { + + struct { + int32 index_; + uint32 segment_ : kSegmentBits; + uint32 type_ : kTypeBits; + }; + struct { + int32 dummy_; + uint32 type_and_segment_; + }; + uint64 value_; + }; +}; + +Tp::Tp(int t, const int segment, const int index) + : index_(index), segment_(segment), type_(t) {} + +inline bool Tp::operator==(const Tp& other) const { + return value_ == other.value_; +} +inline bool Tp::operator!=(const Tp& other) const { + return value_ != other.value_; +} + +class Range { + public: + inline Range(const Tp& position, const int count) __attribute__((always_inline)); + inline Tp GetBeginTokenPosition() const; + inline Tp GetEndTokenPosition() const; + private: + Tp position_; + int count_; + int16 begin_index_; + int16 end_index_; +}; + +inline Range::Range(const Tp& position, + const int count) + : position_(position), count_(count), begin_index_(0), end_index_(0) + { } + +inline Tp Range::GetBeginTokenPosition() const { + return position_; +} +inline Tp Range::GetEndTokenPosition() const { + return Tp(position_.GetType(), position_.GetSegment(), + position_.GetIndex() + count_); +} + +int main () +{ + Range range(Tp(0, 0, 3), 0); + if (!(range.GetBeginTokenPosition() == Tp(0, 0, 3))) + abort (); + + if (!(range.GetEndTokenPosition() == Tp(0, 0, 3))) + abort(); + + return 0; +} diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c index df19dd1cc51..45ebd93698d 100644 --- a/gcc/tree-sra.c +++ b/gcc/tree-sra.c @@ -2876,7 +2876,8 @@ sra_modify_assign (gimple *stmt, gimple_stmt_iterator *gsi) there to do the copying and then load the scalar replacements of the LHS. This is what the first branch does. */ - if (gimple_has_volatile_ops (*stmt) + if (modify_this_stmt + || gimple_has_volatile_ops (*stmt) || contains_vce_or_bfcref_p (rhs) || contains_vce_or_bfcref_p (lhs)) { -- 2.30.2