[llvm] [AMDGPU] Remove legalicty checks from imm folding in shrink. NFCI. (PR #69539)

Stanislav Mekhanoshin via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 18 17:23:01 PDT 2023


https://github.com/rampitec updated https://github.com/llvm/llvm-project/pull/69539

>From 4672a2fa1fcd071b8f7f4a68572b1126dddaf34f Mon Sep 17 00:00:00 2001
From: Stanislav Mekhanoshin <Stanislav.Mekhanoshin at amd.com>
Date: Wed, 18 Oct 2023 17:12:36 -0700
Subject: [PATCH 1/2] [AMDGPU] Remove legalicty checks from imm folding in
 shrink. NFCI.

The immediate legality checks are now embedded into the isOperandLegal().
It is not needed to check it again.
---
 llvm/lib/Target/AMDGPU/SIShrinkInstructions.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/llvm/lib/Target/AMDGPU/SIShrinkInstructions.cpp b/llvm/lib/Target/AMDGPU/SIShrinkInstructions.cpp
index 4159dc694c1e037..88c75a0f86a6c13 100644
--- a/llvm/lib/Target/AMDGPU/SIShrinkInstructions.cpp
+++ b/llvm/lib/Target/AMDGPU/SIShrinkInstructions.cpp
@@ -104,8 +104,7 @@ bool SIShrinkInstructions::foldImmediates(MachineInstr &MI,
         bool ConstantFolded = false;
 
         if (TII->isOperandLegal(MI, Src0Idx, &MovSrc)) {
-          if (MovSrc.isImm() &&
-              (isInt<32>(MovSrc.getImm()) || isUInt<32>(MovSrc.getImm()))) {
+          if (MovSrc.isImm()) {
             Src0.ChangeToImmediate(MovSrc.getImm());
             ConstantFolded = true;
           } else if (MovSrc.isFI()) {

>From 64c3613788cd04d484359c28c3d2591934ec2e69 Mon Sep 17 00:00:00 2001
From: Stanislav Mekhanoshin <Stanislav.Mekhanoshin at amd.com>
Date: Wed, 18 Oct 2023 17:12:36 -0700
Subject: [PATCH 2/2] [AMDGPU] Remove legality checks from imm folding in
 shrink. NFCI.

The immediate legality checks are now embedded into the isOperandLegal().
It is not needed to check it again.
---
 llvm/lib/Target/AMDGPU/SIShrinkInstructions.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/llvm/lib/Target/AMDGPU/SIShrinkInstructions.cpp b/llvm/lib/Target/AMDGPU/SIShrinkInstructions.cpp
index 4159dc694c1e037..88c75a0f86a6c13 100644
--- a/llvm/lib/Target/AMDGPU/SIShrinkInstructions.cpp
+++ b/llvm/lib/Target/AMDGPU/SIShrinkInstructions.cpp
@@ -104,8 +104,7 @@ bool SIShrinkInstructions::foldImmediates(MachineInstr &MI,
         bool ConstantFolded = false;
 
         if (TII->isOperandLegal(MI, Src0Idx, &MovSrc)) {
-          if (MovSrc.isImm() &&
-              (isInt<32>(MovSrc.getImm()) || isUInt<32>(MovSrc.getImm()))) {
+          if (MovSrc.isImm()) {
             Src0.ChangeToImmediate(MovSrc.getImm());
             ConstantFolded = true;
           } else if (MovSrc.isFI()) {



More information about the llvm-commits mailing list