[llvm-dev] sdiv in array subscript

14 views
Skip to first unread message

Hongbin Zheng via llvm-dev

unread,
Mar 29, 2017, 1:35:39 PM3/29/17
to llvm-dev
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"?

Thanks
Hongbin

Friedman, Eli via llvm-dev

unread,
Mar 29, 2017, 2:00:00 PM3/29/17
to Hongbin Zheng, llvm-dev

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

_______________________________________________
LLVM Developers mailing list
llvm...@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

Hongbin Zheng via llvm-dev

unread,
Mar 29, 2017, 4:05:51 PM3/29/17
to Friedman, Eli, llvm-dev
Hi Eli,

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

Thanks
Hongbin

Friedman, Eli via llvm-dev

unread,
Mar 29, 2017, 5:15:36 PM3/29/17
to Hongbin Zheng, llvm-dev
On 3/29/2017 1:05 PM, Hongbin Zheng wrote:
> Hi Eli,
>
> Thanks. Do you mean ideally we should extend SimplifyIndVar to do the
> sdiv->udiv replacement?

I haven't really looked into it closely, but it seems to make sense.

-Eli

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

_______________________________________________

Hongbin Zheng via llvm-dev

unread,
Mar 29, 2017, 6:00:32 PM3/29/17
to Friedman, Eli, llvm-dev
On Wed, Mar 29, 2017 at 2:15 PM, Friedman, Eli <efri...@codeaurora.org> wrote:
On 3/29/2017 1:05 PM, Hongbin Zheng wrote:
Hi Eli,

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

I haven't really looked into it closely, but it seems to make sense.
Ok.

Once I extend SimplifyIndVar, e.g. the  simplifyUsersOfIV function. How I can add a regression test for the extension? simplifyUsersOfIV  is not a pass.

Thanks
Hongbin

Friedman, Eli via llvm-dev

unread,
Mar 29, 2017, 6:18:46 PM3/29/17
to Hongbin Zheng, llvm-dev
On 3/29/2017 3:00 PM, Hongbin Zheng wrote:


On Wed, Mar 29, 2017 at 2:15 PM, Friedman, Eli <efri...@codeaurora.org> wrote:
On 3/29/2017 1:05 PM, Hongbin Zheng wrote:
Hi Eli,

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

I haven't really looked into it closely, but it seems to make sense.
Ok.

Once I extend SimplifyIndVar, e.g. the  simplifyUsersOfIV function. How I can add a regression test for the extension? simplifyUsersOfIV  is not a pass.

It gets called by -indvars.

Hongbin Zheng via llvm-dev

unread,
Mar 29, 2017, 11:40:05 PM3/29/17
to Friedman, Eli, llvm-dev
Hi Eli,


Thanks
Hongbin
 
Reply all
Reply to author
Forward
0 new messages