On Thu, May 21, 2015 at 09:24:37AM -0600, Jeff Law wrote:
> When combine needs to split a complex insn, it will canonicalize a 
> simple (mult X (const_int Y)) where Y is a power of 2 into the expected 
> (ashift X (const_int Y')) if the (mult ...) is selected as a split point.
> 
> However if the split point is (plus (mult (X (const_int Y)) Z) combine 
> fails to canonicalize.

> OK for the trunk?

Okay.  Something went wrong with your changelog though.  Rebasing
changelogs is a recipe for disaster.


The following is just copy-paste, but anyway...

> +       /* Similarly for (plus (mult FOO (const_int pow2))).  */
> +       if (split_code == PLUS
> +           && GET_CODE (XEXP (*split, 0)) == MULT
> +           && CONST_INT_P (XEXP (XEXP (*split, 0), 1))
> +           && INTVAL (XEXP (XEXP (*split, 0), 1)) > 0
> +           && (i = exact_log2 (UINTVAL (XEXP (XEXP (*split, 0), 1)))) >= 0)

INTVAL (..) > 0  here disallows 1<<63 while exact_log2 allows it
(with a 64-bit HWI).  Most places don't check the > 0 and it doesn't
seem necessary in the places that do.

This won't ever trigger for a SImode 1<<31 either.

None of this matters when we're just looking at scaled indexing, of
course.  But exact_log2 is much harder to use correctly than to use
it incorrectly :-(


Segher

Reply via email to