diff options
author | Richard Biener <rguenther@suse.de> | 2022-02-07 09:31:07 +0100 |
---|---|---|
committer | Richard Biener <rguenther@suse.de> | 2022-02-07 09:37:59 +0100 |
commit | 70430001b74d0f67386a6b3642c857b3389cd5d0 (patch) | |
tree | 29c05d2c608dd767b103751694248e4d21d8682b /gcc/gimple-expr.cc | |
parent | e66ba0f55c000152df63fc67c11a64f79122ef86 (diff) | |
download | gcc-70430001b74d0f67386a6b3642c857b3389cd5d0.zip gcc-70430001b74d0f67386a6b3642c857b3389cd5d0.tar.gz gcc-70430001b74d0f67386a6b3642c857b3389cd5d0.tar.bz2 |
middle-end/104402 - split out _Complex compares from COND_EXPRs
This makes sure we always have a _Complex compare split to a
different stmt for the compare operand in a COND_EXPR on GIMPLE.
Complex lowering doesn't handle this and the change is something
we want for all kind of compares at some point.
2022-02-07 Richard Biener <rguenther@suse.de>
PR middle-end/104402
* gimple-expr.cc (is_gimple_condexpr): _Complex typed
compares are not valid.
* tree-cfg.cc (verify_gimple_assign_ternary): For COND_EXPR
check is_gimple_condexpr.
* gcc.dg/torture/pr104402.c: New testcase.
Diffstat (limited to 'gcc/gimple-expr.cc')
-rw-r--r-- | gcc/gimple-expr.cc | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/gcc/gimple-expr.cc b/gcc/gimple-expr.cc index 05b1274..f9a650b 100644 --- a/gcc/gimple-expr.cc +++ b/gcc/gimple-expr.cc @@ -602,12 +602,16 @@ is_gimple_lvalue (tree t) /* Helper for is_gimple_condexpr and is_gimple_condexpr_for_cond. */ static bool -is_gimple_condexpr_1 (tree t, bool allow_traps) +is_gimple_condexpr_1 (tree t, bool allow_traps, bool allow_cplx) { - return (is_gimple_val (t) || (COMPARISON_CLASS_P (t) - && (allow_traps || !tree_could_throw_p (t)) - && is_gimple_val (TREE_OPERAND (t, 0)) - && is_gimple_val (TREE_OPERAND (t, 1)))); + tree op0; + return (is_gimple_val (t) + || (COMPARISON_CLASS_P (t) + && (allow_traps || !tree_could_throw_p (t)) + && ((op0 = TREE_OPERAND (t, 0)), true) + && (allow_cplx || TREE_CODE (TREE_TYPE (op0)) != COMPLEX_TYPE) + && is_gimple_val (op0) + && is_gimple_val (TREE_OPERAND (t, 1)))); } /* Return true if T is a GIMPLE condition. */ @@ -615,7 +619,9 @@ is_gimple_condexpr_1 (tree t, bool allow_traps) bool is_gimple_condexpr (tree t) { - return is_gimple_condexpr_1 (t, true); + /* Always split out _Complex type compares since complex lowering + doesn't handle this case. */ + return is_gimple_condexpr_1 (t, true, false); } /* Like is_gimple_condexpr, but does not allow T to trap. */ @@ -623,7 +629,7 @@ is_gimple_condexpr (tree t) bool is_gimple_condexpr_for_cond (tree t) { - return is_gimple_condexpr_1 (t, false); + return is_gimple_condexpr_1 (t, false, true); } /* Return true if T is a gimple address. */ |