[llvm-bugs] [Bug 37849] New: Missed optimization: invariant code motion
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Jun 19 03:42:57 PDT 2018
https://bugs.llvm.org/show_bug.cgi?id=37849
Bug ID: 37849
Summary: Missed optimization: invariant code motion
Product: libraries
Version: trunk
Hardware: PC
OS: Windows NT
Status: NEW
Severity: enhancement
Priority: P
Component: Scalar Optimizations
Assignee: unassignedbugs at nondot.org
Reporter: m-takahiro at jp.fujitsu.com
CC: llvm-bugs at lists.llvm.org
I compiled the following code at -O3 with loop unrolling disabled to make it
easy to see generated IRs.
---------------------
void foo(float * restrict a, float * restrict b, const int N) {
for (int i = 1; i < N; ++i)
a[i] = a[0] + b[i];
}
---------------------
Clang version is as follows:
---------------------
$ clang --version
clang version 7.0.0 (trunk 335036)
---------------------
And generated IRs are as follows:
---------------------
; <label>:8: ; pre
%9 = phi i64 [ 1, %5 ], [ %15, %8 ]
%10 = load float, float* %0, align 4, !tbaa !2
%11 = getelementptr inbounds float, float* %1, i64 %9
%12 = load float, float* %11, align 4, !tbaa !2
%13 = fadd float %10, %12
%14 = getelementptr inbounds float, float* %0, i64 %9
store float %13, float* %14, align 4, !tbaa !2
%15 = add nuw nsw i64 %9, 1
%16 = icmp eq i64 %15, %6
br i1 %16, label %7, label %8
---------------------
'a[0]' (%10) is invariant inside the loop because an initial value of induction
variable is 1 and its value is incremented by 1. So, I think invariant code
motion can be applied.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180619/4f2791f5/attachment.html>
More information about the llvm-bugs
mailing list