<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - Poor codegen for targets with no native shifts"
href="https://bugs.llvm.org/show_bug.cgi?id=43559">43559</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Poor codegen for targets with no native shifts
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Common Code Generator Code
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>joan.lluch@icloud.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>This is an extension of <a class="bz_bug_link
bz_status_RESOLVED bz_closed"
title="RESOLVED FIXED - Poor codegen for targets with no native shifts"
href="show_bug.cgi?id=43542">bug 43542</a>. This is a report of the same issue for the
following functions:
DAGCombiner::SimplifySelectCC
DAGCombiner::foldSelectCCToShiftAnd
static SDValue foldExtendedSignBitTest
Creation of shifts as a replacement of selects or extensions should be avoided
in DAGCombiner if shifts are not efficiently supported by the target.
The following IR functions are originators or the reported issue through
slightly different paths for the MSP430 target:
; Function Attrs: norecurse nounwind readnone
define dso_local i16 @test0(i16 %a) local_unnamed_addr #0 {
entry:
%cmp = icmp slt i16 %a, 0
%cond = select i1 %cmp, i16 -1, i16 0
ret i16 %cond
}
; Function Attrs: norecurse nounwind readnone
define dso_local i16 @test1(i16 %a) local_unnamed_addr #0 {
entry:
%cmp = icmp slt i16 %a, 0
%cond = select i1 %cmp, i16 1, i16 0
ret i16 %cond
}
; Function Attrs: norecurse nounwind readnone
define dso_local i16 @test2(i16 %a) local_unnamed_addr #0 {
entry:
%cmp = icmp slt i16 %a, 0
%cond = select i1 %cmp, i16 2, i16 0
ret i16 %cond
}
; Function Attrs: norecurse nounwind readnone
define dso_local i16 @test3(i16 %a) local_unnamed_addr #0 {
entry:
%cmp = icmp slt i16 %a, 0
%cond = select i1 %cmp, i16 3, i16 0
ret i16 %cond
}
The resulting code for the MSP430 is this, which is suboptimal:
.globl test0
.p2align 1
.type test0,@function
test0:
swpb r12
sxt r12
rra r12
rra r12
rra r12
rra r12
rra r12
rra r12
rra r12
ret
.Lfunc_end0:
.size test0, .Lfunc_end0-test0
.globl test1
.p2align 1
.type test1,@function
test1:
swpb r12
mov.b r12, r12
clrc
rrc r12
rra r12
rra r12
rra r12
rra r12
rra r12
rra r12
ret
.Lfunc_end1:
.size test1, .Lfunc_end1-test1
.globl test2
.p2align 1
.type test2,@function
test2:
swpb r12
mov.b r12, r12
clrc
rrc r12
rra r12
rra r12
rra r12
rra r12
rra r12
and #2, r12
ret
.Lfunc_end2:
.size test2, .Lfunc_end2-test2
.globl test3
.p2align 1
.type test3,@function
test3:
swpb r12
sxt r12
rra r12
rra r12
rra r12
rra r12
rra r12
rra r12
rra r12
and #3, r12
ret
.Lfunc_end3:
.size test3, .Lfunc_end3-test3</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>