[PATCH] D24700: [InstCombine] optimize unsigned icmp of inc/dec like signed

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 19 13:40:01 PDT 2016


spatel added a comment.

Not sure if this is easier to read, but if the existing code was rewritten with something like this:

  auto getNewPred = [](CmpInst::Predicate P, Value *AddConstant) {
    if (!match(AddConstant, m_AllOnes()) && !match(AddConstant, m_One()))
      return ICmpInst::BAD_ICMP_PREDICATE;
  
    switch (P) {
    case CmpInst::ICMP_SLT: return CmpInst::ICMP_SLE;
    case CmpInst::ICMP_SGE: return CmpInst::ICMP_SGT;
    case CmpInst::ICMP_SLE: return CmpInst::ICMP_SLT;
    case CmpInst::ICMP_SGT: return CmpInst::ICMP_SGE;
    default: return CmpInst::BAD_ICMP_PREDICATE;
    }
  };

Then your patch would just be to add some cases to the switch?


https://reviews.llvm.org/D24700





More information about the llvm-commits mailing list