When compile the following case and look at the SCEV analysis, I notice that the first two loops don't have a LoopInvariantBackedgeTakenCount (surprising) and the last one does (not surprising, except in the context of the first two examples). *void p4(int *A, int *B, long int n) {* * for (char i = 0; i < n; i++) {* * A[i + 2] = i;* * *B++ = A[i];* * }* *}* * * *void p5(int *A, int *B, long int n) {* * for (short i = 0; i < n; i++) {* * A[i + 2] = i;* * *B++ = A[i];* * }* *}* * * *void p6(int *A, int *B, long int n) {* * for (int i = 0; i < n; i++) {* * A[i + 2] = i;* * *B++ = A[i];* * }* *}* Why the difference? Is there a reason we don't implement all the loops using 64-bit values? Thanks, Preston -------------- next part -------------- An HTML attachment was scrubbed... URL: <lists.llvm.org/pipermail/llvm-dev/attachments/20120619/bf4fe2b2/attachment.html>
On Tue, Jun 19, 2012 at 10:21 PM, Preston Briggs <preston.briggs at gmail.com> wrote:> When compile the following case and look at the SCEV analysis, I notice that > the first two loops don't have a LoopInvariantBackedgeTakenCount > (surprising) and the last one does (not surprising, except in the context of > the first two examples). > > void p4(int *A, int *B, long int n) { > for (char i = 0; i < n; i++) { > A[i + 2] = i; > *B++ = A[i]; > } > } > > void p5(int *A, int *B, long int n) { > for (short i = 0; i < n; i++) { > A[i + 2] = i; > *B++ = A[i]; > } > } > > void p6(int *A, int *B, long int n) { > for (int i = 0; i < n; i++) { > A[i + 2] = i; > *B++ = A[i]; > } > } > > > Why the difference? Is there a reason we don't implement all the loops using > 64-bit values?The third loop is provably not an infinite loop, thanks to C's signed overflow rules; we can't tell whether the first two loops might be infinite. -Eli
On Wed, 20 Jun 2012 02:18:49 -0700 Eli Friedman <eli.friedman at gmail.com> wrote:> On Tue, Jun 19, 2012 at 10:21 PM, Preston Briggs > <preston.briggs at gmail.com> wrote: > > When compile the following case and look at the SCEV analysis, I > > notice that the first two loops don't have a > > LoopInvariantBackedgeTakenCount (surprising) and the last one does > > (not surprising, except in the context of the first two examples). > > > > void p4(int *A, int *B, long int n) { > > for (char i = 0; i < n; i++) { > > A[i + 2] = i; > > *B++ = A[i]; > > } > > } > > > > void p5(int *A, int *B, long int n) { > > for (short i = 0; i < n; i++) { > > A[i + 2] = i; > > *B++ = A[i]; > > } > > } > > > > void p6(int *A, int *B, long int n) { > > for (int i = 0; i < n; i++) { > > A[i + 2] = i; > > *B++ = A[i]; > > } > > } > > > > > > Why the difference? Is there a reason we don't implement all the > > loops using 64-bit values? > > The third loop is provably not an infinite loop, thanks to C's signed > overflow rules; we can't tell whether the first two loops might be > infinite.This seems like a perfect example of where LLVM might want to emit a note to the user (especially when we have loop vectorization and other transformations). -Hal> > -Eli > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu llvm.cs.uiuc.edu > lists.cs.uiuc.edu/mailman/listinfo/llvmdev-- Hal Finkel Postdoctoral Appointee Leadership Computing Facility Argonne National Laboratory