[all-commits] [llvm/llvm-project] 1b85c6: [X86] apply mulx optimization for two-wide mul ins...
Takashi Idobe via All-commits
all-commits at lists.llvm.org
Sat Mar 14 06:02:51 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 1b85c6322df16e9af285652bc85b3e7d7ff71c5e
https://github.com/llvm/llvm-project/commit/1b85c6322df16e9af285652bc85b3e7d7ff71c5e
Author: Takashi Idobe <idobetakashi at gmail.com>
Date: 2026-03-14 (Sat, 14 Mar 2026)
Changed paths:
M llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
A llvm/test/CodeGen/X86/mul-lohi-no-implicit-copy.ll
Log Message:
-----------
[X86] apply mulx optimization for two-wide mul instruction (mull, mulq) (#185127)
References: https://github.com/llvm/llvm-project/pull/184462
In the discussion for the linked PR, which removes unnecessary register
to register moves when one operand is in %rdx for mulx, the point was
brought up that this pattern also happens for mull and mulq.
The IR below:
```llvm
declare i32 @foo32()
declare i64 @foo64()
define i32 @mul32_no_implicit_copy(i32 %a0) {
%a1 = call i32 @foo32()
%a2 = call { i32, i1 } @llvm.umul.with.overflow.i32(i32 %a0, i32 %a1)
%a3 = extractvalue { i32, i1 } %a2, 0
ret i32 %a3
}
define i64 @mul64_no_implicit_copy(i64 %a0) {
%a1 = call i64 @foo64()
%a2 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %a0, i64 %a1)
%a3 = extractvalue { i64, i1 } %a2, 0
ret i64 %a3
}
```
Generates this code on current HEAD:
```asm
mul32_no_implicit_copy: # @mul32_no_implicit_copy
push rbx
mov ebx, edi
call foo32 at PLT
mov ecx, eax
mov eax, ebx
mul ecx
pop rbx
ret
mul64_no_implicit_copy: # @mul64_no_implicit_copy
push rbx
mov rbx, rdi
call foo64 at PLT
mov rcx, rax
mov rax, rbx
mul rcx
pop rbx
ret
```
Where the register shuffling before the mul is the same pattern as for
mulx in the previous PR.
With this branch it generates this code now:
```asm
mul32_no_implicit_copy:
pushq %rbx
movl %edi, %ebx
callq foo32 at PLT
mull %ebx
popq %rbx
retq
mul64_no_implicit_copy:
pushq %rbx
movq %rdi, %rbx
callq foo64 at PLT
mulq %rbx
popq %rbx
retq
```
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list