[llvm] [ARM] Use target constant for MVE fixed fp convert constant (PR #227250)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 29 02:58:32 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-arm
Author: David Green (davemgreen)
<details>
<summary>Changes</summary>
If the constant already exists then we would reuse the constant in a register instead of using an immediate, as the instruction requires. Use a TargetConstant to make sure we generate an immediate.
Fixes #<!-- -->226592
---
Full diff: https://github.com/llvm/llvm-project/pull/227250.diff
2 Files Affected:
- (modified) llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp (+1-1)
- (modified) llvm/test/CodeGen/Thumb2/mve-vcvt-fixed-to-float.ll (+15)
``````````diff
diff --git a/llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp b/llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp
index 61b679d55fb47..b85cff2f8ae2b 100644
--- a/llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp
+++ b/llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp
@@ -3327,7 +3327,7 @@ bool ARMDAGToDAGISel::transformFixedFloatingPointConversion(SDNode *N,
return false;
SmallVector<SDValue, 3> Ops{
- VecVal, CurDAG->getConstant(FracBits, SDLoc(N), MVT::i32)};
+ VecVal, CurDAG->getTargetConstant(FracBits, SDLoc(N), MVT::i32)};
AddEmptyMVEPredicateToOps(Ops, SDLoc(N), Type);
unsigned int Opcode;
diff --git a/llvm/test/CodeGen/Thumb2/mve-vcvt-fixed-to-float.ll b/llvm/test/CodeGen/Thumb2/mve-vcvt-fixed-to-float.ll
index 38a2cfc1a579d..08cc77da6afe7 100644
--- a/llvm/test/CodeGen/Thumb2/mve-vcvt-fixed-to-float.ll
+++ b/llvm/test/CodeGen/Thumb2/mve-vcvt-fixed-to-float.ll
@@ -1029,3 +1029,18 @@ define arm_aapcs_vfpcc <4 x float> @vcvt_negative2(<4 x i32> %0) {
%3 = fmul <4 x float> %2, <float 0xBE00000000000000, float 0xBE00000000000000, float 0xBE00000000000000, float 0xBE00000000000000>
ret <4 x float> %3
}
+
+define arm_aapcs_vfpcc <4 x float> @extra_4(<4 x i32> %2, ptr %p, i32 %i) {
+; CHECK-LABEL: extra_4:
+; CHECK: @ %bb.0: @ %entry
+; CHECK-NEXT: vcvt.f32.s32 q0, q0, #4
+; CHECK-NEXT: eor r1, r1, #4
+; CHECK-NEXT: str r1, [r0]
+; CHECK-NEXT: bx lr
+entry:
+ %3 = sitofp <4 x i32> %2 to <4 x float>
+ %4 = fmul nnan <4 x float> %3, splat (float 6.250000e-02)
+ %o = xor i32 %i, 4
+ store i32 %o, ptr %p
+ ret <4 x float> %4
+}
``````````
</details>
https://github.com/llvm/llvm-project/pull/227250
More information about the llvm-commits
mailing list