Skip to content

[GlobalISel][KnownBits] Simplify G_CONSTANT handling #91946

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 13, 2024

Conversation

Pierre-vh
Copy link
Contributor

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.

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.
@llvmbot
Copy link
Member

llvmbot commented May 13, 2024

@llvm/pr-subscribers-llvm-globalisel

Author: Pierre van Houtryve (Pierre-vh)

Changes

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.


Full diff: https://github.com/llvm/llvm-project/pull/91946.diff

1 Files Affected:

  • (modified) llvm/lib/CodeGen/GlobalISel/GISelKnownBits.cpp (+1-4)
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: {

@Pierre-vh Pierre-vh merged commit 4ff45ee into llvm:main May 13, 2024
3 of 4 checks passed
@Pierre-vh Pierre-vh deleted the fix_gconst_kb branch May 13, 2024 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants