<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 - [X86][BMI2] Investigate uses of 32-bit MULX on x86_64"
href="https://bugs.llvm.org/show_bug.cgi?id=34232">34232</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[X86][BMI2] Investigate uses of 32-bit MULX on x86_64
</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>Windows NT
</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>Backend: X86
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>llvm-dev@redking.me.uk
</td>
</tr>
<tr>
<th>CC</th>
<td>craig.topper@gmail.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>We don't use MULX32 at all 64-bit targets. Not only do we miss avoiding
touching RFLAGS (which I don't think we make use of at all for
MULX/SARX/etc.?), but we miss opportunities such as:
uint32_t mulhi(uint32_t x, uint32_t y) {
uint64_t xx = x;
uint64_t yy = y;
uint64_t rr = xx * yy;
return (uint32_t)(rr >> 32);
}
define i32 @mulhi(i32, i32) {
%3 = zext i32 %0 to i64
%4 = zext i32 %1 to i64
%5 = mul i64 %4, %3
%6 = lshr i64 %5, 32
%7 = trunc i64 %6 to i32
ret i32 %7
}
haswell x86_64:
mulhi:
movl %edi, %ecx
movl %esi, %eax
imulq %rcx, %rax
shrq $32, %rax
retq
haswell i686:
mulhi:
movl 8(%esp), %edx
mulxl 4(%esp), %ecx, %eax
retl
In comparison, for MULX64:
define i64 @mulhi64(i32, i32) {
%3 = zext i64 %0 to i128
%4 = zext i64 %1 to i128
%5 = mul i128 %4, %3
%6 = lshr i128 %5, 32
%7 = trunc i128 %6 to i64
ret i64 %7
}
mulhi64:
movq %rdi, %rdx
mulxq %rsi, %rcx, %rax
retq</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>