[llvm] [SelectionDAG] Use LAST_INTEGER_VALUETYPE instead of i64 (PR #98299)

Dmitry Borisenkov via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 10 03:46:54 PDT 2024


https://github.com/akiramenai created https://github.com/llvm/llvm-project/pull/98299

When looking for a largest legal integer type for a target `TargetLowering::findOptimalMemOpLowering` assumes that `MVT::i64` is the largets possible integer type. The patch removes this assumption and uses `MVT::LAST_INTEGER_VALUETYPE` instead.

>From de0bace07f9b6139cf979f962273c0da02d45c80 Mon Sep 17 00:00:00 2001
From: Dmitry Borisenkov <dmitriy.borisenkov89 at gmail.com>
Date: Wed, 10 Jul 2024 13:41:30 +0300
Subject: [PATCH] [SelectionDAG] Use LAST_INTEGER_VALUETYPE instead of i64

When looking for a largest legal integer type for a target
`TargetLowering::findOptimalMemOpLowering` assumes that
`MVT::i64` is the largets possible integer type. The patch removes this
assumption and uses `MVT::LAST_INTEGER_VALUETYPE` instead.
---
 llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
index 458f962802b4c..690a86bd4606c 100644
--- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
@@ -209,7 +209,7 @@ bool TargetLowering::findOptimalMemOpLowering(
     // Use the largest integer type whose alignment constraints are satisfied.
     // We only need to check DstAlign here as SrcAlign is always greater or
     // equal to DstAlign (or zero).
-    VT = MVT::i64;
+    VT = MVT::LAST_INTEGER_VALUETYPE;
     if (Op.isFixedDstAlign())
       while (Op.getDstAlign() < (VT.getSizeInBits() / 8) &&
              !allowsMisalignedMemoryAccesses(VT, DstAS, Op.getDstAlign()))
@@ -217,7 +217,7 @@ bool TargetLowering::findOptimalMemOpLowering(
     assert(VT.isInteger());
 
     // Find the largest legal integer type.
-    MVT LVT = MVT::i64;
+    MVT LVT = MVT::LAST_INTEGER_VALUETYPE;
     while (!isTypeLegal(LVT))
       LVT = (MVT::SimpleValueType)(LVT.SimpleTy - 1);
     assert(LVT.isInteger());



More information about the llvm-commits mailing list