[llvm-dev] sdiv in array subscript

Friedman, Eli via llvm-dev llvm-dev at lists.llvm.org
Wed Mar 29 10:59:53 PDT 2017


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/SimplifyIndVar.cpp.

-Eli

-- 
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project



More information about the llvm-dev mailing list