Skip to content

[X86] combineStore - remove rangedata when converting 64-bit copies to f64 load/store #147904

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 10, 2025

Conversation

RKSimon
Copy link
Collaborator

@RKSimon RKSimon commented Jul 10, 2025

We're changing from i64 to f64 - we can't retain any range metadata

Fixes #147781

…o f64 load/store

We're changing from i64 to f64 - we can't retain any range metadata

Fixes llvm#147781
@llvmbot
Copy link
Member

llvmbot commented Jul 10, 2025

@llvm/pr-subscribers-backend-x86

Author: Simon Pilgrim (RKSimon)

Changes

We're changing from i64 to f64 - we can't retain any range metadata

Fixes #147781


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

2 Files Affected:

  • (modified) llvm/lib/Target/X86/X86ISelLowering.cpp (+4)
  • (added) llvm/test/CodeGen/X86/pr147781.ll (+19)
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 347ba1262b66b..1ad1b47a94d28 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -53574,6 +53574,10 @@ static SDValue combineStore(SDNode *N, SelectionDAG &DAG,
 
     SDLoc LdDL(Ld);
     SDLoc StDL(N);
+
+    // Remove any range metadata as we're converting to f64 load/store.
+    Ld->getMemOperand()->clearRanges();
+
     // Lower to a single movq load/store pair.
     SDValue NewLd = DAG.getLoad(MVT::f64, LdDL, Ld->getChain(),
                                 Ld->getBasePtr(), Ld->getMemOperand());
diff --git a/llvm/test/CodeGen/X86/pr147781.ll b/llvm/test/CodeGen/X86/pr147781.ll
new file mode 100644
index 0000000000000..9f65fd5984e7b
--- /dev/null
+++ b/llvm/test/CodeGen/X86/pr147781.ll
@@ -0,0 +1,19 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=i686-pc-windows-gnu -verify-machineinstrs | FileCheck %s
+
+; Ensure i64 !range data is stripped when converting to f64 load/store.
+define void @test(ptr %p, ptr %p2) #0 {
+; CHECK-LABEL: test:
+; CHECK:       # %bb.0:
+; CHECK-NEXT:    movl {{[0-9]+}}(%esp), %ecx
+; CHECK-NEXT:    movl {{[0-9]+}}(%esp), %eax
+; CHECK-NEXT:    movsd {{.*#+}} xmm0 = mem[0],zero
+; CHECK-NEXT:    movsd %xmm0, (%eax)
+; CHECK-NEXT:    retl
+  %val = load i64, ptr %p, align 8, !range !0
+  store i64 %val, ptr %p2, align 8
+  ret void
+}
+
+attributes #0 = { "target-cpu"="pentium4" }
+!0 = !{i64 1, i64 0}

Copy link
Contributor

@nikic nikic left a comment

Choose a reason for hiding this comment

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

LGTM

@RKSimon RKSimon merged commit 75656d8 into llvm:main Jul 10, 2025
11 checks passed
@RKSimon RKSimon deleted the x86-memcpy64-norangedata branch July 10, 2025 08:32
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.

[X86] Assertion failure: Range metadata and load type must match!
3 participants