------- Comment #2 from rguenth at gcc dot gnu dot org  2008-05-22 16:10 -------
  t = (int) ((long int) U1 * 3 >> 2) + 2;
  Y = (int) ((long int) (t * t) * 954437177 >> 29);

if combined is folded to

  Y = (int) (((long int) (int) ((long int) U1 * 3 >> 2) * 954437177 +
1908874354) * (long int) ((int) ((long int) U1 * 3 >> 2) + 2) >> 29);

We can see that for

int foo(int x)
{
  return (long)(((int)((long)x * 3) + 2) * (int)((long)x * 3)) * 2;
}

the conversion to long is distributed on the operands and the
multiplication by 2 is then re-associated.

I bet this is extract_muldiv at its work again.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rguenth at gcc dot gnu dot
                   |                            |org
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
           Keywords|                            |wrong-code
      Known to fail|                            |4.1.3 4.2.4 4.3.0
   Last reconfirmed|0000-00-00 00:00:00         |2008-05-22 16:10:38
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36300

Reply via email to