[llvm-bugs] [Bug 30833] New: [ppc] Use cmplwi insead of rlwinm. to compare bool var
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Oct 28 14:59:15 PDT 2016
https://llvm.org/bugs/show_bug.cgi?id=30833
Bug ID: 30833
Summary: [ppc] Use cmplwi insead of rlwinm. to compare bool var
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
Compile the following code with options -m64 -O2
struct A {
long V() const { return f4 ? f1: f2; }
bool IsDone() const { return f3 >= V(); }
long f1, f2;
int f3;
bool f4;
};
struct B {
bool IsDone() const { return f6 >= f5.f1; }
void Next();
A f5;
int f6;
};
extern A qux();
extern B bar();
void B::Next() {
while (f5.IsDone()) {
f5 = qux();
}
}
void foo() {
B iter = bar();
while (!iter.IsDone()) {
iter.Next();
}
}
LLVM generates:
...
lwz 4, 112(31)
lbz 5, 116(31)
ld 7, 104(31)
addi 29, 31, 128
.p2align 4
.LBB1_2: # %while.body
# =>This Loop Header: Depth=1
# Child Loop BB1_3 Depth 2
rlwinm. 8, 5, 0, 24, 31 // A
extsw 8, 4
isel 9, 7, 3, 2
cmpd 8, 9
blt 0, .LBB1_5
.p2align 4
.LBB1_3: # %while.body.i
# Parent Loop BB1_2 Depth=1
# => This Inner Loop Header: Depth=2
mr 3, 29
bl _Z3quxv
nop
lxvd2x 0, 0, 29
stxvd2x 0, 0, 30
ori 2, 2, 0
ld 3, 144(31)
std 3, 112(31)
ori 2, 2, 0
lbz 5, 116(31)
ld 3, 96(31)
ld 7, 104(31)
lwa 4, 112(31)
cmplwi 5, 0 // B
isel 6, 7, 3, 2
cmpd 4, 6
bge 0, .LBB1_3
# BB#4: # %while.cond.backedge.loopexit
# in Loop: Header=BB1_2 Depth=1
lwz 6, 120(31)
.LBB1_5: # %while.cond.backedge
# in Loop: Header=BB1_2 Depth=1
extsw 8, 6
cmpd 8, 3
blt 0, .LBB1_2
...
Note that instruction A is actually comparing a bool variable loaded from
116(31), it can be replaced with a slightly faster instruction cmplwi, just
like instruction B.
--
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/20161028/b649b46b/attachment.html>
More information about the llvm-bugs
mailing list