[LLVMbugs] [Bug 22689] New: Two Addr Instruction pass could be improved further
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Tue Feb 24 22:12:10 PST 2015
http://llvm.org/bugs/show_bug.cgi?id=22689
Bug ID: 22689
Summary: Two Addr Instruction pass could be improved further
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: Common Code Generator Code
Assignee: unassignedbugs at nondot.org
Reporter: wmi at google.com
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
A problem was identified in TwoAddrInstruction pass and a patch was propsed in
http://reviews.llvm.org/D7806.
However, there are other cases that the patch cannot handle currently. Like the
following one:
1.c:
int M, total;
int A[100], B[100], C[100];
volatile int g;
void goo(int);
void foo() {
int i, a, b, x, y, z;
a = 3;
for (i = 0; i < M; i++) {
b = i;
z = g;
y = b * a;
x = y + z;
a = g;
goo(b);
total += x;
}
}
~/workarea/llvm-r230041/build/bin/clang -O2 -fno-vectorize -fno-unroll-loops -S
1.c
kernel loop in 1.s:
.LBB0_2: # %for.body
movl g(%rip), %eax
imull %ebx, %ebp
addl %eax, %ebp
movl g(%rip), %r14d
movl %ebx, %edi
callq goo
addl %ebp, total(%rip)
incl %ebx
cmpl M(%rip), %ebx
movl %r14d, %ebp
jl .LBB0_2
The reg copy insn "movl %r14d, %ebp" could be removed if we switch the
positions of "z = g;" and "y = b * a;" in 1.c
2.c:
int M, total;
int A[100], B[100], C[100];
volatile int g;
void goo(int);
void foo() {
int i, a, b, x, y, z;
a = 3;
for (i = 0; i < M; i++) {
b = i;
y = b * a; // here is the difference with 1.c
z = g; // here is the difference with 1.c
x = y + z;
a = g;
goo(b);
total += x;
}
}
~/workarea/llvm-r230041/build/bin/clang -O2 -fno-vectorize -fno-unroll-loops -S
2.c
kernel loop in 2.s:
.LBB0_2: # %for.body
imull %ebx, %ebp
movl g(%rip), %r14d
addl %ebp, %r14d
movl g(%rip), %ebp
movl %ebx, %edi
callq goo
addl %r14d, total(%rip)
incl %ebx
cmpl M(%rip), %ebx
jl .LBB0_2
The bug is better to be fixed incrementally, so filed this bug to track the
problem.
--
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/20150225/a0bd6705/attachment.html>
More information about the llvm-bugs
mailing list