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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |15.3
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=118637
            Summary|{CEIL,ROUND}_DIV_EXPR       |[15/16 Regression]
                   |produces wrong results when |{CEIL,ROUND}_DIV_EXPR
                   |constant operand is 2 or    |produces wrong results when
                   |power of 2 with O2 flag     |constant operand is 2 or
                   |                            |power of 2 with O2 flag
           Keywords|                            |wrong-code

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
In the inline case we get:
Matching expression match.pd:2944, gimple-match-8.cc:90
Matching expression match.pd:2948, gimple-match-4.cc:77
Matching expression match.pd:2958, gimple-match-6.cc:91
Matching expression match.pd:2964, gimple-match-10.cc:84
Matching expression match.pd:2960, gimple-match-6.cc:105
Matching expression match.pd:2964, gimple-match-10.cc:84
Matching expression match.pd:2940, gimple-match-8.cc:65
Matching expression match.pd:2948, gimple-match-4.cc:77
Matching expression match.pd:197, gimple-match-6.cc:22
gimple_simplified to D_6 = 2;

Oh:
Applying pattern match.pd:991, gimple-match-4.cc:5994
gimple_simplified to D_2 = a_1(D) >> 3;

That is:
```
(for div (trunc_div ceil_div floor_div round_div exact_div)
#if GIMPLE
 /* Canonicalize unsigned t / 4 to t >> 2.  */
 (simplify
  (div @0 integer_pow2p@1)
  (if (INTEGRAL_TYPE_P (type)
       && (TYPE_UNSIGNED (type) || tree_expr_nonnegative_p (@0)))
   (rshift @0 { build_int_cst (integer_type_node,
                               wi::exact_log2 (wi::to_wide (@1))); })))

```

Which was added in r15-7223-g92a5c5100c2519.

I think that is only valid for trunc_div, floor_div, and exact_div.

Reply via email to