[PATCH] D94862: [InstCombine] Replace one-use select operand based on condition

Theodore Popp via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 18 14:45:33 PST 2021


tpopp added a comment.

I've been unable to create a reproducer because of other optimizations getting in the way, but I'm seeing a case of infinite loops in inst combine due to both `CmpLHS` and `CmpRHS` being constants.

My issue at least is fixed by:

  -    if (isa<Constant>(CmpRHS) && !isa<ConstantExpr>(CmpRHS))
  +    auto IsConstant = [](auto *V) {return isa<Constant>(V) && !isa<ConstantExpr>(V);};
  +    if (IsConstant(CmpRHS) && !IsConstant(CmpLHS))

That possible fix is here: https://reviews.llvm.org/D94934

My workday is over, so feel free to steal the solution or to offer a different one :)  If this is a sign of a larger issue or leads to other problems, I'd propose we should roll this back as it's breaking existing code.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D94862/new/

https://reviews.llvm.org/D94862



More information about the llvm-commits mailing list