[PATCH] D149325: [DAG] Do not call computeKnownBits from isKnownToBeAPowerOfTwo

Jay Foad via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 27 01:36:51 PDT 2023


foad created this revision.
foad added reviewers: craig.topper, RKSimon, spatel.
Herald added subscribers: StephenFan, hiraditya.
Herald added a project: All.
foad requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

The only way known bits could help identify a known power of two is if
it knows exactly which power of two it is, i.e. if it is a known
constant. But in that case the value should have been simplified to a
constant already. So save some compile time by not calling
computeKnownBits.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149325

Files:
  llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp


Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -4022,10 +4022,7 @@
 
   // More could be done here, though the above checks are enough
   // to handle some common cases.
-
-  // Fall back to computeKnownBits to catch other known cases.
-  KnownBits Known = computeKnownBits(Val);
-  return (Known.countMaxPopulation() == 1) && (Known.countMinPopulation() == 1);
+  return false;
 }
 
 unsigned SelectionDAG::ComputeNumSignBits(SDValue Op, unsigned Depth) const {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D149325.517482.patch
Type: text/x-patch
Size: 643 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230427/3bcb7f41/attachment.bin>


More information about the llvm-commits mailing list