diff options
author | Richard Biener <rguenther@suse.de> | 2022-12-01 10:12:28 +0100 |
---|---|---|
committer | Richard Biener <rguenther@suse.de> | 2022-12-01 10:53:41 +0100 |
commit | abf05583dbc86a6667b63f5bda6ba57fe55a1b25 (patch) | |
tree | befc2c277eb2254a84124f509c76f41e20567281 /gcc/gimple-predicate-analysis.h | |
parent | 8629f212af0acb113879d0bc45291c54743790f1 (diff) | |
download | gcc-abf05583dbc86a6667b63f5bda6ba57fe55a1b25.zip gcc-abf05583dbc86a6667b63f5bda6ba57fe55a1b25.tar.gz gcc-abf05583dbc86a6667b63f5bda6ba57fe55a1b25.tar.bz2 |
tree-optimization/107937 - uninit predicate simplification fixup
The following changes the predicate representation to record the
value of a predicate with an empty set of AND predicates. That's
necessary to properly represent the conservative fallback for the
def vs use predicates. Since simplification now can result in
such an empty set this distinction becomes important and we need
to check for this as we otherwise ICE.
PR tree-optimization/107937
* gimple-predicate-analysis.h (predicate::is_true): New.
(predicate::is_false): Likewise.
(predicate::empty_val): Likewise.
(uninit_analysis::uninit_analysis): Properly initialize
def_preds.
* gimple-predicate-analysis.cc (simplify_1b): Indicate
whether the chain became empty.
(predicate::simplify): Release emptied chain before removing it.
(predicate::normalize): Replace temporary object with assertion.
(uninit_analysis::is_use_guarded): Deal with predicates
that simplify to true/false.
* gcc.dg/pr107937.c: New testcase.
Diffstat (limited to 'gcc/gimple-predicate-analysis.h')
-rw-r--r-- | gcc/gimple-predicate-analysis.h | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/gcc/gimple-predicate-analysis.h b/gcc/gimple-predicate-analysis.h index 972af5e..c4a7ed5 100644 --- a/gcc/gimple-predicate-analysis.h +++ b/gcc/gimple-predicate-analysis.h @@ -45,7 +45,7 @@ class predicate { public: /* Construct with the specified EVAL object. */ - predicate () : m_preds (vNULL) { } + predicate (bool empty_val) : m_preds (vNULL), m_cval (empty_val) { } /* Copy. */ predicate (const predicate &rhs) : m_preds (vNULL) { *this = rhs; } @@ -60,6 +60,21 @@ class predicate return m_preds.is_empty (); } + bool is_true () const + { + return is_empty () && m_cval; + } + + bool is_false () const + { + return is_empty () && !m_cval; + } + + bool empty_val () const + { + return m_cval; + } + const pred_chain_union chain () const { return m_preds; @@ -92,8 +107,10 @@ private: bool simplify_3 (); bool simplify_4 (); - /* Representation of the predicate expression(s). */ + /* Representation of the predicate expression(s). The predicate is + m_cval || m_preds[0] || ... */ pred_chain_union m_preds; + bool m_cval; }; /* Represents a complex Boolean predicate expression. */ @@ -119,7 +136,7 @@ class uninit_analysis /* Construct with the specified EVAL object. */ uninit_analysis (func_t &eval) - : m_phi_def_preds (), m_eval (eval) { } + : m_phi_def_preds (false), m_eval (eval) { } /* Copy. */ uninit_analysis (const uninit_analysis &rhs) = delete; |