Skip to content

Conversation

@mahesh-attarde
Copy link
Contributor

Precommit for #144473

@llvmbot
Copy link
Member

llvmbot commented Jun 19, 2025

@llvm/pr-subscribers-backend-x86

Author: Mahesh-Attarde (mahesh-attarde)

Changes

Precommit for #144473


Full diff: https://github.com/llvm/llvm-project/pull/144928.diff

1 Files Affected:

  • (added) llvm/test/CodeGen/X86/isel-bitcast.ll (+62)
diff --git a/llvm/test/CodeGen/X86/isel-bitcast.ll b/llvm/test/CodeGen/X86/isel-bitcast.ll
new file mode 100644
index 0000000000000..2fcb122020708
--- /dev/null
+++ b/llvm/test/CodeGen/X86/isel-bitcast.ll
@@ -0,0 +1,62 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
+; RUN: llc < %s -mtriple=i686-- | FileCheck %s -check-prefixes=X86
+; RUN: llc < %s -mtriple=x86_64--| FileCheck %s -check-prefixes=X64
+; RUN: llc < %s -mtriple=i686-- | FileCheck %s -check-prefixes=X86
+; RUN: llc < %s -mtriple=x86_64--| FileCheck %s -check-prefixes=X64
+
+define i64 @test1(double %t) {
+; X86-LABEL: test1:
+; X86:       # %bb.0:
+; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT:    movl {{[0-9]+}}(%esp), %edx
+; X86-NEXT:    retl
+;
+; X64-LABEL: test1:
+; X64:       # %bb.0:
+; X64-NEXT:    movq %xmm0, %rax
+; X64-NEXT:    retq
+        %u = bitcast double %t to i64           ; <i64> [#uses=1]
+        ret i64 %u
+}
+
+define double @test2(i64 %t) {
+; X86-LABEL: test2:
+; X86:       # %bb.0:
+; X86-NEXT:    fldl {{[0-9]+}}(%esp)
+; X86-NEXT:    retl
+;
+; X64-LABEL: test2:
+; X64:       # %bb.0:
+; X64-NEXT:    movq %rdi, %xmm0
+; X64-NEXT:    retq
+        %u = bitcast i64 %t to double           ; <double> [#uses=1]
+        ret double %u
+}
+
+define i32 @test3(float %t) {
+; X86-LABEL: test3:
+; X86:       # %bb.0:
+; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT:    retl
+;
+; X64-LABEL: test3:
+; X64:       # %bb.0:
+; X64-NEXT:    movd %xmm0, %eax
+; X64-NEXT:    retq
+        %u = bitcast float %t to i32            ; <i32> [#uses=1]
+        ret i32 %u
+}
+
+define float @test4(i32 %t) {
+; X86-LABEL: test4:
+; X86:       # %bb.0:
+; X86-NEXT:    flds {{[0-9]+}}(%esp)
+; X86-NEXT:    retl
+;
+; X64-LABEL: test4:
+; X64:       # %bb.0:
+; X64-NEXT:    movd %edi, %xmm0
+; X64-NEXT:    retq
+        %u = bitcast i32 %t to float            ; <float> [#uses=1]
+        ret float %u
+}

; X64: # %bb.0:
; X64-NEXT: movq %xmm0, %rax
; X64-NEXT: retq
%u = bitcast double %t to i64 ; <i64> [#uses=1]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove the comments (; <i64> [#uses=1] etc.)

; RUN: llc < %s -mtriple=i686-- | FileCheck %s -check-prefixes=X86
; RUN: llc < %s -mtriple=x86_64--| FileCheck %s -check-prefixes=X64

define i64 @test1(double %t) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(style) don't number tests - bitcast_i64_f64 etc. are much better (and makes things much easier once the file grows)

@mahesh-attarde
Copy link
Contributor Author

closing.

@mahesh-attarde mahesh-attarde deleted the bitcast_test branch July 15, 2025 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants