[LLVMdev] Scalar Evolution not canonalizing division?
Duncan Sands
baldrick at free.fr
Thu Oct 28 01:34:24 CDT 2010
Hi Nick,
> For the store to the array A in the loop I get this scalar evolution function:
>
> {((8 * ({0,+,(8 * %m)}<%for.cond> /u 8)) + %vla),+,8}<%for.cond5>
>
> For me it seems the devision by "8" is not canonical. Is there any reason
> this can not be simplified to:
>
> {((1 * ({0,+,(1 * %m)}<%for.cond>)) + %vla),+,8}<%for.cond5>
>
>
> Because we have to assume 2's complement arithmetic. Unless we know (or can
> prove) that the "8 *" won't overflow, we can't safely fold it away against "/u 8".
in the original code, overflow corresponds to undefined behaviour (wrapping
around the end of the address space) so it should be possible to deduce that
this transform is ok using more context.
Ciao,
Duncan.
More information about the LLVMdev
mailing list