https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115138

--- Comment #20 from Iain Buclaw <ibuclaw at gcc dot gnu.org> ---
Stepping through both the stage1-gcc/gdc and stage2-gcc/gdc compilers, there is
an apparent divergence in behaviour at this point in gimplify.cc

 6527│   /* Now that the LHS is gimplified, re-gimplify the RHS if our initial
 6528│      guess for the predicate was wrong.  */
 6529│   gimple_predicate final_pred = rhs_predicate_for (*to_p);
 6530│   if (final_pred != initial_pred)
 6531│     {
 6532│       ret = gimplify_expr (from_p, pre_p, post_p, final_pred,
fb_rvalue);
 6533│       if (ret == GS_ERROR)
 6534│         return ret;
 6535│     }


It looks like the stage2 compiler treats the if condition as being always true
- though I could be looking at apples and oranges here as one is -O0 whilst the
other is -O2.

stage1:
```
   0x0000000001421561 <+2288>:  call   0x141dc8e
<_Z17rhs_predicate_forP9tree_node>
   0x0000000001421566 <+2293>:  mov    %rax,-0x90(%rbp)
   0x000000000142156d <+2300>:  mov    -0x90(%rbp),%rax
   0x0000000001421574 <+2307>:  cmp    -0x98(%rbp),%rax
   0x000000000142157b <+2314>:  je     0x14215c1
   0x000000000142157d <+2316>:  mov    -0x90(%rbp),%rcx
   0x0000000001421584 <+2323>:  mov    -0xf8(%rbp),%rdx
   0x000000000142158b <+2330>:  mov    -0xf0(%rbp),%rsi
   0x0000000001421592 <+2337>:  mov    -0xb0(%rbp),%rax
   0x0000000001421599 <+2344>:  mov    $0x1,%r8d
   0x000000000142159f <+2350>:  mov    %rax,%rdi
   0x00000000014215a2 <+2353>:  call   0x1456eac
<_Z13gimplify_exprPP9tree_nodePP6gimpleS4_PFbS0_Ei>
   0x00000000014215a7 <+2358>:  mov    %eax,-0xd4(%rbp)
   0x00000000014215ad <+2364>:  cmpl   $0xfffffffe,-0xd4(%rbp)
   0x00000000014215b4 <+2371>:  jne    0x14215c1
   0x00000000014215b6 <+2373>:  mov    -0xd4(%rbp),%eax
   0x00000000014215bc <+2379>:  jmp    0x1422709
   0x00000000014215c1 <+2384>:  mov    -0xb0(%rbp),%rax
```

stage2
```

   0x00000000010d637c <+668>:   call   0x105d030 <_Z13is_gimple_regP9tree_node>
   0x00000000010d6381 <+673>:   mov    $0x10a2ad0,%ecx
   0x00000000010d6386 <+678>:   mov    %r12,%rdx
   0x00000000010d6389 <+681>:   mov    %rbx,%rsi
   0x00000000010d638c <+684>:   test   %al,%al
   0x00000000010d638e <+686>:   mov    $0x10a21d0,%eax
   0x00000000010d6393 <+691>:   mov    $0x1,%r8d
   0x00000000010d6399 <+697>:   mov    %r14,%rdi
   0x00000000010d639c <+700>:   cmovne %rax,%rcx
   0x00000000010d63a0 <+704>:   call   0x10b3700
<_Z13gimplify_exprPP9tree_nodePP6gimpleS4_PFbS0_Ei>
   0x00000000010d63a5 <+709>:   cmp    $0xfffffffe,%eax
   0x00000000010d63a8 <+712>:   je     0x10d6538
```

Reply via email to