[PATCH] D24280: [IndVarSimplify] Prefer sext over zext when widening IV if it is non-negative and has a GEP user

Li Huang via llvm-commits llvm-commits at lists.llvm.org
Sat Sep 10 18:45:44 PDT 2016


lihuang updated this revision to Diff 70955.
lihuang added a comment.

Canonicalize on zext when IV is known non-negative. Then, for each def-use pair of IV users, choose the kind of extension based on the following strategy:

  if the narrow def is non-negative, use either sext or zext which applies to the narrow user.
  otherwise, use the same extension applied to narrow def for the narrow user. 

I added a map in class WidenIV to track the kind of extension used for each IV user, and basically changed every query to WideIV::IsSigned to a query into this map. The reason is, each narrow user should rely on its narrow def to choose sext/zext rather than the signedness of original IV, as the IV could be either sign extended or zero extended. Should be able to integrate this map with the Widened set, but I want to make sure I am in the right direction first.

This change includes the logic in https://reviews.llvm.org/D18867, so added those 2 test cases here. The 3rd test case comes from TSVC/174 (regression caused by https://reviews.llvm.org/D18777). All sext/zext to IV users in these 3 tests should be removed.


https://reviews.llvm.org/D24280

Files:
  lib/Transforms/Scalar/IndVarSimplify.cpp
  test/Transforms/IndVarSimplify/iv-widen-elim-ext.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24280.70955.patch
Type: text/x-patch
Size: 18176 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160911/517016db/attachment.bin>


More information about the llvm-commits mailing list