[llvm] [GlobalISel][KnownBits] Simplify G_CONSTANT handling (PR #91946)

Pierre van Houtryve via llvm-commits llvm-commits at lists.llvm.org
Mon May 13 04:59:19 PDT 2024


https://github.com/Pierre-vh updated https://github.com/llvm/llvm-project/pull/91946

>From 9adbd6b21f8e40d806e045249fe87c932835783f Mon Sep 17 00:00:00 2001
From: pvanhout <pierre.vanhoutryve at amd.com>
Date: Mon, 13 May 2024 13:38:58 +0200
Subject: [PATCH] [GlobalISel][KnownBits] Simplify G_CONSTANT handling

We called getIConstantVRegVal which again queried MRI to get the VReg def. We already have the def, so just get the CImm directly. It can't fail.
---
 llvm/lib/CodeGen/GlobalISel/GISelKnownBits.cpp | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/llvm/lib/CodeGen/GlobalISel/GISelKnownBits.cpp b/llvm/lib/CodeGen/GlobalISel/GISelKnownBits.cpp
index c8199a42d15c3..32d607cfd71a7 100644
--- a/llvm/lib/CodeGen/GlobalISel/GISelKnownBits.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/GISelKnownBits.cpp
@@ -256,10 +256,7 @@ void GISelKnownBits::computeKnownBitsImpl(Register R, KnownBits &Known,
     break;
   }
   case TargetOpcode::G_CONSTANT: {
-    auto CstVal = getIConstantVRegVal(R, MRI);
-    if (!CstVal)
-      break;
-    Known = KnownBits::makeConstant(*CstVal);
+    Known = KnownBits::makeConstant(MI.getOperand(1).getCImm()->getValue());
     break;
   }
   case TargetOpcode::G_FRAME_INDEX: {



More information about the llvm-commits mailing list