[llvm-bugs] [Bug 25581] New: [ppc] redundant extsw and sldi instructions
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Nov 19 16:09:59 PST 2015
https://llvm.org/bugs/show_bug.cgi?id=25581
Bug ID: 25581
Summary: [ppc] redundant extsw and sldi instructions
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: Backend: PowerPC
Assignee: unassignedbugs at nondot.org
Reporter: carrot at google.com
CC: llvm-bugs at lists.llvm.org
Classification: Unclassified
The following is a hot function from 471.omnetpp
void cMessageHeap::shiftup(int from)
{
// restores heap structure (in a sub-heap)
int i,j;
cMessage *temp;
i=from;
while ((j=2*i) <= n)
{
if (j<n && (*h[j] > *h[j+1])) //direction
j++;
if (*h[i] > *h[j]) //is change necessary?
{
temp=h[j];
(h[j]=h[i])->heapindex=j;
(h[i]=temp)->heapindex=i;
i=j;
}
else
break;
}
}
When compiled with options -fno-strict-aliasing -O2 -m64 -mvsx -mcpu=power8
I got:
_ZN12cMessageHeap7shiftupEi: # @_ZN12cMessageHeap7shiftupEi
.Lfunc_begin14:
# BB#0: # %entry
lwz 7, 64(3)
slwi 8, 4, 1
cmpw 8, 7
bgtlr 0
# BB#1: # %while.body.lr.ph
crxor 20, 20, 20
li 5, 144
creqv 21, 21, 21
.align 4
.LBB14_2: # %while.body
# =>This Inner Loop Header: Depth=1
mr 6, 4
cmpw 8, 7
bge 0, .LBB14_9
# BB#3: # %land.lhs.true
# in Loop: Header=BB14_2 Depth=1
ori 4, 8, 1 // A
extsw 9, 8 // B
ld 7, 56(3)
cror 1, 20, 20
extsw 10, 4 // C
sldi 9, 9, 3 // D
sldi 11, 10, 3 // E
ldx 10, 7, 9
ldx 9, 7, 11
lxsdx 0, 10, 5
lxsdx 1, 9, 5
xscmpudp 1, 0, 1
blt 1, .LBB14_8
...
In the source code note that j comes from (i*2), so the lowest bit is 0, and
then we have following conclusion:
1) j+1 equals to j|1, so instruction A actually computes j+1
2) extsw(j+1) equals to extsw(j) + 1
3) (j+1) << 3 equals to j<<3 + 8
So instructions ABCDE can be replaced with shorter code sequence
extsw 9, 8
sldi 9, 9, 3
addi 11, 9, 8
--
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/20151120/3212cece/attachment-0001.html>
More information about the llvm-bugs
mailing list