@@ -42,7 +42,8 @@ along with GCC; see the file COPYING3. If not see
#include "vr-values.h"
#include "gimple-ssa-evrp-analyze.h"
-evrp_range_analyzer::evrp_range_analyzer () : stack (10)
+evrp_range_analyzer::evrp_range_analyzer (bool update_global_ranges)
+ : stack (10), m_update_global_ranges (update_global_ranges)
{
edge e;
edge_iterator ei;
@@ -107,6 +108,8 @@ evrp_range_analyzer::try_find_new_range (tree name,
void
evrp_range_analyzer::set_ssa_range_info (tree lhs, value_range *vr)
{
+ gcc_assert (m_update_global_ranges);
+
/* Set the SSA with the value range. */
if (INTEGRAL_TYPE_P (TREE_TYPE (lhs)))
{
@@ -213,6 +216,7 @@ evrp_range_analyzer::record_ranges_from_incoming_edge (basic_block bb)
continue;
push_value_range (vrs[i].first, vrs[i].second);
if (is_fallthru
+ && m_update_global_ranges
&& all_uses_feed_or_dominated_by_stmt (vrs[i].first, stmt))
{
set_ssa_range_info (vrs[i].first, vrs[i].second);
@@ -267,7 +271,8 @@ evrp_range_analyzer::record_ranges_from_phis (basic_block bb)
vr_values->update_value_range (lhs, &vr_result);
/* Set the SSA with the value range. */
- set_ssa_range_info (lhs, &vr_result);
+ if (m_update_global_ranges)
+ set_ssa_range_info (lhs, &vr_result);
}
}
@@ -309,7 +314,8 @@ evrp_range_analyzer::record_ranges_from_stmt (gimple *stmt, bool temporary)
/* Case one. We can just update the underlying range
information as well as the global information. */
vr_values->update_value_range (output, &vr);
- set_ssa_range_info (output, &vr);
+ if (m_update_global_ranges)
+ set_ssa_range_info (output, &vr);
}
else
{
@@ -23,7 +23,7 @@ along with GCC; see the file COPYING3. If not see
class evrp_range_analyzer
{
public:
- evrp_range_analyzer (void);
+ evrp_range_analyzer (bool update_global_ranges);
~evrp_range_analyzer (void)
{
delete vr_values;
@@ -70,6 +70,9 @@ class evrp_range_analyzer
/* STACK holds the old VR. */
auto_vec<std::pair <tree, value_range*> > stack;
+
+ /* True if we are updating global ranges, false otherwise. */
+ bool m_update_global_ranges;
};
#endif /* GCC_GIMPLE_SSA_EVRP_ANALYZE_H */
@@ -70,6 +70,7 @@ class evrp_dom_walker : public dom_walker
public:
evrp_dom_walker ()
: dom_walker (CDI_DOMINATORS),
+ evrp_range_analyzer (true),
evrp_folder (evrp_range_analyzer.get_vr_values ())
{
need_eh_cleanup = BITMAP_ALLOC (NULL);
@@ -121,7 +121,9 @@ struct format_result;
class sprintf_dom_walker : public dom_walker
{
public:
- sprintf_dom_walker () : dom_walker (CDI_DOMINATORS) {}
+ sprintf_dom_walker ()
+ : dom_walker (CDI_DOMINATORS),
+ evrp_range_analyzer (false) {}
~sprintf_dom_walker () {}
edge before_dom_children (basic_block) FINAL OVERRIDE;
new file mode 100644
@@ -0,0 +1,14 @@
+# At -Og no pass records the global range information
+# necessary to optimize the strnlen calls down to
+# a constant. The framework assumes that the test
+# will never call strnlen when the optimizer is
+# enabled. So we filter out the -Og run here.
+
+set torture_eval_before_compile {
+ if {[string match {*-Og*} "$option"]} {
+ continue
+ }
+}
+
+return 0
+
@@ -578,6 +578,7 @@ public:
: dom_walker (direction, REACHABLE_BLOCKS),
m_const_and_copies (const_and_copies),
m_avail_exprs_stack (avail_exprs_stack),
+ evrp_range_analyzer (true),
m_dummy_cond (dummy_cond) { }
virtual edge before_dom_children (basic_block);