Skip to content

Commit 6502817

Browse files
committed
[AArch64] Remove redundant FMOV for zero-extended i32/i16 loads to f64
Previously, a load from i32 or i16, followed by zero-extension to i64 and a bitcast to f64, would emit separate FMOV instructions. This patch introduces new corresponding TableGen patterns to avoid the unnecessary FMOV. Tests added: - load_u64_from_u32.ll - load_u64_from_u16.ll
1 parent 61a0653 commit 6502817

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
2+
; RUN: llc -mtriple=aarch64-linux-gnu -o - %s | FileCheck %s
3+
4+
define double @_Z9load_u64_from_u16_testPj(ptr %n){
5+
; CHECK-LABEL: _Z9load_u64_from_u16_testPj:
6+
; CHECK: // %bb.0: // %entry
7+
; CHECK-NEXT: ldr h0, [x0]
8+
; CHECK-NEXT: ret
9+
entry:
10+
%0 = load i16, ptr %n, align 2
11+
%conv = zext i16 %0 to i64
12+
%1 = bitcast i64 %conv to double
13+
ret double %1
14+
}
15+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
2+
; RUN: llc -mtriple=aarch64-linux-gnu -o - %s | FileCheck %s
3+
4+
define double @_Z9load_u64_from_u32_testPj(ptr %n) {
5+
; CHECK-LABEL: _Z9load_u64_from_u32_testPj:
6+
; CHECK: // %bb.0: // %entry
7+
; CHECK-NEXT: ldr s0, [x0]
8+
; CHECK-NEXT: ret
9+
entry:
10+
%0 = load i32, ptr %n, align 4
11+
%conv = zext i32 %0 to i64
12+
%1 = bitcast i64 %conv to double
13+
ret double %1
14+
}

0 commit comments

Comments
 (0)