[llvm] [InstCombine] Remove some of the complexity-based canonicalization (PR #91185)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Wed May 8 23:24:20 PDT 2024
================
@@ -132,21 +132,18 @@ class LLVM_LIBRARY_VISIBILITY InstCombiner {
/// This routine maps IR values to various complexity ranks:
/// 0 -> undef
/// 1 -> Constants
- /// 2 -> Other non-instructions
- /// 3 -> Arguments
- /// 4 -> Cast and (f)neg/not instructions
- /// 5 -> Other instructions
+ /// 2 -> Cast and (f)neg/not instructions
+ /// 3 -> Other instructions and arguments
static unsigned getComplexity(Value *V) {
- if (isa<Instruction>(V)) {
- if (isa<CastInst>(V) || match(V, m_Neg(PatternMatch::m_Value())) ||
- match(V, m_Not(PatternMatch::m_Value())) ||
- match(V, m_FNeg(PatternMatch::m_Value())))
- return 4;
- return 5;
- }
- if (isa<Argument>(V))
- return 3;
- return isa<Constant>(V) ? (isa<UndefValue>(V) ? 0 : 1) : 2;
+ if (isa<Constant>(V))
+ return isa<UndefValue>(V) ? 0 : 1;
+
+ if (isa<CastInst>(V) || match(V, m_Neg(PatternMatch::m_Value())) ||
+ match(V, m_Not(PatternMatch::m_Value())) ||
+ match(V, m_FNeg(PatternMatch::m_Value())))
+ return 2;
+
+ return 3;
----------------
nikic wrote:
I'm not sure I get what you mean here. The exact values used here don't matter, it's just a relative order.
https://github.com/llvm/llvm-project/pull/91185
More information about the llvm-commits
mailing list