[PATCH] D103656: [ScalarEvolution] Ensure backedge-taken counts are not pointers.

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 4 10:17:18 PDT 2021


efriedma added a comment.

For pointers where the index type is smaller than the pointer type, coming up with the right result is a little tricky.  As far as I can tell from the LangRef rules, icmp compares all the bits of the pointer, not just the index bits?  So I guess we can special-case comparisons where both sides have the same pointer base: the non-index bits will be the same.  If both sides have the same pointer base, and we've inferred some sort of nowrap, we can then convert the icmp to compare the index bits.  I guess we can handle non-integral pointers the same way.

But I don't want to try to implement this logic without any real-world testing.  As far as I know, no in-tree targets use this feature.  So I'll leave it to someone who cares about such targets, and I don't think it should block this patch.



================
Comment at: llvm/test/Transforms/IndVarSimplify/lftr-reuse.ll:32-33
 ; CHECK-NEXT:    [[INCDEC_PTR]] = getelementptr inbounds i8, i8* [[P_02]], i32 1
-; CHECK-NEXT:    [[EXITCOND:%.*]] = icmp ne i8* [[INCDEC_PTR]], [[ADD_PTR]]
-; CHECK-NEXT:    br i1 [[EXITCOND]], label [[FOR_BODY]], label [[FOR_END_LOOPEXIT:%.*]]
+; CHECK-NEXT:    [[CMP:%.*]] = icmp ult i8* [[INCDEC_PTR]], [[ADD_PTR]]
+; CHECK-NEXT:    br i1 [[CMP]], label [[FOR_BODY]], label [[FOR_END_LOOPEXIT:%.*]]
 ; CHECK:       for.end.loopexit:
----------------
lebedev.ri wrote:
> I *think* this is not a non-integral pointer, and i think GEP index size (in DL) isn't too small,
> so i'm not sure what is going on here?
Maybe something to do with the icmp in the preheader; I'll look further.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103656/new/

https://reviews.llvm.org/D103656



More information about the llvm-commits mailing list