[llvm-bugs] [Bug 41272] New: Failure to hoist constant mask out of loop
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Mar 28 04:56:37 PDT 2019
https://bugs.llvm.org/show_bug.cgi?id=41272
Bug ID: 41272
Summary: Failure to hoist constant mask out of loop
Product: libraries
Version: trunk
Hardware: PC
OS: Windows NT
Status: NEW
Severity: enhancement
Priority: P
Component: Backend: X86
Assignee: unassignedbugs at nondot.org
Reporter: llvm-dev at redking.me.uk
CC: craig.topper at gmail.com, llvm-bugs at lists.llvm.org,
llvm-dev at redking.me.uk, spatel+llvm at rotateright.com
https://godbolt.org/z/YXhpEv
#include <stdint.h>
uint64_t sum_mask32(const uint64_t *p, int len) {
uint64_t sum = 0;
for(int i = 0; i < len; i++) {
sum += *p++ & 0x80008000;
}
return sum;
}
With clang -Os the loop kernel is:
.LBB0_4: # =>This Inner Loop Header: Depth=1
movq (%rdi,%rdx,8), %rsi
andl $-2147450880, %esi # imm = 0x80008000
addq %rsi, %rax
incq %rdx
cmpl %edx, %ecx
jne .LBB0_4
retq
With clang -O3 the unrolled kernel is even worse:
.LBB0_9: # =>This Inner Loop Header: Depth=1
movq (%rdi), %rcx
movq 8(%rdi), %rdx
andl $-2147450880, %ecx # imm = 0x80008000
addq %rax, %rcx
andl $-2147450880, %edx # imm = 0x80008000
addq %rcx, %rdx
movq 16(%rdi), %rcx
andl $-2147450880, %ecx # imm = 0x80008000
addq %rdx, %rcx
movq 24(%rdi), %rax
addq $32, %rdi
andl $-2147450880, %eax # imm = 0x80008000
addq %rcx, %rax
addl $4, %r9d
jne .LBB0_9
testl %r8d, %r8d
je .LBB0_7
--
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/20190328/9afdda3b/attachment.html>
More information about the llvm-bugs
mailing list