[llvm] [LegalizeTypes] Use APInt::extractBits instead of getRawData. (PR #103607)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 13 21:51:08 PDT 2024


https://github.com/topperc created https://github.com/llvm/llvm-project/pull/103607

We shouldn't expose that APInt stores uint64_t values if we don't need to.

>From 8bfc932d77d2bb88037fa1057c3dbfe267eddc67 Mon Sep 17 00:00:00 2001
From: Craig Topper <craig.topper at sifive.com>
Date: Tue, 13 Aug 2024 21:47:40 -0700
Subject: [PATCH] [LegalizeTypes] Use APInt::extractBits instead of getRawData.

We shouldn't expose that APInt stores uint64_t values if we don't
need to.
---
 llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
index 7c1cf129d5462f..0437d3c11bb2b6 100644
--- a/llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
@@ -1494,8 +1494,8 @@ void DAGTypeLegalizer::ExpandFloatRes_ConstantFP(SDNode *N, SDValue &Lo,
   APInt C = cast<ConstantFPSDNode>(N)->getValueAPF().bitcastToAPInt();
   SDLoc dl(N);
   const fltSemantics &Sem = NVT.getFltSemantics();
-  Lo = DAG.getConstantFP(APFloat(Sem, APInt(64, C.getRawData()[1])), dl, NVT);
-  Hi = DAG.getConstantFP(APFloat(Sem, APInt(64, C.getRawData()[0])), dl, NVT);
+  Lo = DAG.getConstantFP(APFloat(Sem, C.extractBits(64, 64)), dl, NVT);
+  Hi = DAG.getConstantFP(APFloat(Sem, C.extractBits(64, 0)), dl, NVT);
 }
 
 void DAGTypeLegalizer::ExpandFloatRes_Unary(SDNode *N, RTLIB::Libcall LC,



More information about the llvm-commits mailing list