PR64817 is lucky that the compare in the testcase was <0 rather than >0. expand_debug_expr used to take the signedness of the expr from the result type, rather than from the operand types, so it the a < 0 test was expanded as LTU rather than LT, and LTU compares with zero are always false, so we short-circuited the most complex debug exprs out.
Reversing the sense of the test is enough to expose them. Even though Jakub's earlier patch for PR64817 avoided the simplify-rtx problems during cfgexpand, var-track still runs afoul of it once the sense of the compare is reversed, as in the testcase below. This patch makes the situation with a<0 as bad as with a>0. Fixing the is left for patch 2 of this series; maybe the testcase should be installed along with it. In my series, this patch was actually #3, that's why I had the testcase with it. However, I found it easier to explain the problem starting out with this one, and including the testcase. I can split out the testcase into a separate patch or install it along with the second patch in the series, if that makes more sense. While staring at the code, I found a couple of typos in comments in cfgexpand, that I fixed as part of this patch. I can split that out too, if I must. Regstrapped on x86_64-linux-gnu and i686-linux-gnu. Ok to install? for gcc/ChangeLog PR debug/64817 * cfgexpand.c (expand_debug_expr): Compute unsignedp from operands for tcc_comparison exprs. Fix typos. for gcc/testsuite/ChangeLog PR debug/64817 * gcc.dg/pr64817-3.c: New. --- gcc/cfgexpand.c | 9 ++++++--- gcc/testsuite/gcc.dg/pr64817-3.c | 13 +++++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/pr64817-3.c diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c index 12021de0..7dfe1f6 100644 --- a/gcc/cfgexpand.c +++ b/gcc/cfgexpand.c @@ -3911,7 +3911,6 @@ expand_debug_expr (tree exp) binary: case tcc_binary: - case tcc_comparison: op1 = expand_debug_expr (TREE_OPERAND (exp, 1)); if (!op1) return NULL_RTX; @@ -3925,6 +3924,10 @@ expand_debug_expr (tree exp) return NULL_RTX; break; + case tcc_comparison: + unsignedp = TYPE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 0))); + goto binary; + case tcc_type: case tcc_statement: gcc_unreachable (); @@ -4006,7 +4009,7 @@ expand_debug_expr (tree exp) op0 = copy_rtx (op0); if (GET_MODE (op0) == BLKmode - /* If op0 is not BLKmode, but BLKmode is, adjust_mode + /* If op0 is not BLKmode, but mode is, adjust_mode below would ICE. While it is likely a FE bug, try to be robust here. See PR43166. */ || mode == BLKmode @@ -5285,7 +5288,7 @@ expand_gimple_basic_block (basic_block bb, bool disable_tail_calls) if (have_debug_uses) { - /* OP is a TERed SSA name, with DEF it's defining + /* OP is a TERed SSA name, with DEF its defining statement, and where OP is used in further debug instructions. Generate a debug temporary, and replace all uses of OP in debug insns with that diff --git a/gcc/testsuite/gcc.dg/pr64817-3.c b/gcc/testsuite/gcc.dg/pr64817-3.c new file mode 100644 index 0000000..3fe0117 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr64817-3.c @@ -0,0 +1,13 @@ +/* PR debug/64817 */ +/* { dg-do compile } */ +/* { dg-options "-O3 -g" } */ + +int a; + +void +foo (void) +{ + int e; + a = ((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((a & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) ^ 1; + e = (a > 0); +} -- Alexandre Oliva, freedom fighter http://FSFLA.org/~lxoliva/ You must be the change you wish to see in the world. -- Gandhi Be Free! -- http://FSFLA.org/ FSF Latin America board member Free Software Evangelist|Red Hat Brasil GNU Toolchain Engineer