[llvm-dev] sdiv in array subscript

Hongbin Zheng via llvm-dev llvm-dev at lists.llvm.org
Wed Mar 29 13:05:45 PDT 2017


Hi Eli,

Thanks. Do you mean ideally we should extend SimplifyIndVar to do the
sdiv->udiv replacement?

Thanks
Hongbin

On Wed, Mar 29, 2017 at 10:59 AM, Friedman, Eli <efriedma at codeaurora.org>
wrote:

> On 3/29/2017 10:35 AM, Hongbin Zheng via llvm-dev wrote:
>
>> Hi llvm-dev,
>>
>> Looks like currently ScalarEvolution will give up if there is a sdiv in
>> array subscript, e.g.
>>
>> int i;
>>
>> A[i * 64 / 2]
>>
>> in this case ScalarEvolution will just return an unknown for (i * 64 / 2).
>>
>> For this case, InstCombine will do the jobs, but in general, is there a
>> pass to deal with the sdiv here? like replace sdiv by udiv based on the
>> range of "i"?
>>
>>
> Instcombine will replace sdiv with udiv if it can prove the sign bit is
> zero, but it isn't very good at analyzing induction variables; we might be
> able to improve that.
>
> There are also some related transforms in lib/Transforms/Utils/SimplifyI
> ndVar.cpp.
>
> -Eli
>
> --
> Employee of Qualcomm Innovation Center, Inc.
> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux
> Foundation Collaborative Project
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170329/2cac4526/attachment.html>


More information about the llvm-dev mailing list