llvm.org GIT mirror llvm / db932d4
[InstCombine] use m_OneUse to reduce code; NFCI git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303090 91177308-0d34-0410-b5e6-96231b3b80d8 Sanjay Patel 3 years ago
1 changed file(s) with 7 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
22112211
22122212 // Canonicalize fcmp_one -> fcmp_oeq
22132213 FCmpInst::Predicate FPred; Value *Y;
2214 if (match(&BI, m_Br(m_FCmp(FPred, m_Value(X), m_Value(Y)),
2215 TrueDest, FalseDest)) &&
2216 BI.getCondition()->hasOneUse())
2214 if (match(&BI, m_Br(m_OneUse(m_FCmp(FPred, m_Value(X), m_Value(Y))),
2215 TrueDest, FalseDest))) {
2216 // TODO: Why are we only transforming these 3 predicates?
22172217 if (FPred == FCmpInst::FCMP_ONE || FPred == FCmpInst::FCMP_OLE ||
22182218 FPred == FCmpInst::FCMP_OGE) {
22192219 FCmpInst *Cond = cast(BI.getCondition());
22242224 Worklist.Add(Cond);
22252225 return &BI;
22262226 }
2227 }
22272228
22282229 // Canonicalize icmp_ne -> icmp_eq
22292230 ICmpInst::Predicate IPred;
2230 if (match(&BI, m_Br(m_ICmp(IPred, m_Value(X), m_Value(Y)),
2231 TrueDest, FalseDest)) &&
2232 BI.getCondition()->hasOneUse())
2231 if (match(&BI, m_Br(m_OneUse(m_ICmp(IPred, m_Value(X), m_Value(Y))),
2232 TrueDest, FalseDest))) {
22332233 if (IPred == ICmpInst::ICMP_NE || IPred == ICmpInst::ICMP_ULE ||
22342234 IPred == ICmpInst::ICMP_SLE || IPred == ICmpInst::ICMP_UGE ||
22352235 IPred == ICmpInst::ICMP_SGE) {
22402240 Worklist.Add(Cond);
22412241 return &BI;
22422242 }
2243 }
22432244
22442245 return nullptr;
22452246 }