[llvm-bugs] [Bug 50996] New: LLVM unable to optimize same associative addition in if-else condition in loop
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Jul 6 07:36:43 PDT 2021
https://bugs.llvm.org/show_bug.cgi?id=50996
Bug ID: 50996
Summary: LLVM unable to optimize same associative addition in
if-else condition in loop
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: Loop Optimizer
Assignee: unassignedbugs at nondot.org
Reporter: TejasSanjay.Joshi at amd.com
CC: llvm-bugs at lists.llvm.org
Created attachment 25004
--> https://bugs.llvm.org/attachment.cgi?id=25004&action=edit
test case
For the same associative calculation in if and else conditions, LLVM seems
unable to recognize it:
void foo(int *a, int *b, int *c)
{
for (int i=0; i<100; ++i) {
if (c[i] > 0)
c[i] = a[i]+b[i];
else
c[i] = b[i]+a[i];
}
}
Even with -Ofast -fno-unroll-loops -ffast-math -S foo.c: Gives the following
main loop:
.LBB0_1:
cmpl $0, (%rdx,%rax,4)
movq %rsi, %r8
cmovgq %rdi, %r8
movq %rdi, %rcx
cmovgq %rsi, %rcx
movl (%rcx,%rax,4), %ecx
addl (%r8,%rax,4), %ecx
movl %ecx, (%rdx,%rax,4)
addq $1, %rax
cmpq $100, %rax
jne .LBB0_1
--
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/20210706/588b1294/attachment.html>
More information about the llvm-bugs
mailing list