https://llvm.org/bugs/show_bug.cgi?id=31557
Bug ID: 31557 Summary: Missed induction variable optimization Product: libraries Version: trunk Hardware: PC OS: Linux Status: NEW Severity: normal Priority: P Component: Scalar Optimizations Assignee: unassignedb...@nondot.org Reporter: car...@google.com CC: llvm-bugs@lists.llvm.org Classification: Unclassified Compile the following code with options --target=powerpc64le-grtev4-linux-gnu -m64 -O2 -mvsx -mcpu=power8 extern void bar(int); void foo(const int* p, int n) { for (int j = 0; j < n; ++j) { int k = p[j]; bar(k); } } I got: clrldi 30, 4, 32 addi 4, 3, -4 .p2align 5 .LBB0_2: # %for.body # =>This Inner Loop Header: Depth=1 lwa 3, 4(4) addi 29, 4, 4 bl _Z3bari nop addi 30, 30, -1 mr 4, 29 cmpldi 30, 0 bne 0, .LBB0_2 Var j is an induction variable, it is only used to index an array, so it can be optimized away, like following clrldi 30, 4, 32 sldi 30, 30, 2 // * add 30, 30, 4 // * addi 4, 3, -4 .p2align 5 .LBB0_2: # %for.body # =>This Inner Loop Header: Depth=1 lwa 3, 4(4) addi 29, 4, 4 bl _Z3bari nop // addi 30, 30, -1 mr 4, 29 cmpld 30, 29 // * bne 0, .LBB0_2 -- You are receiving this mail because: You are on the CC list for the bug.
_______________________________________________ llvm-bugs mailing list llvm-bugs@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs