[llvm] [Instcombine] Fix infinite loop in visitSelectInst. (PR #173704)

Justin Lebar via llvm-commits llvm-commits at lists.llvm.org
Sat Dec 27 11:54:21 PST 2025


================
@@ -4790,18 +4790,20 @@ Instruction *InstCombinerImpl::visitSelectInst(SelectInst &SI) {
   // select (trunc nsw X to i1), X, Y --> select (trunc nsw X to i1), -1, Y
   // select (trunc nsw X to i1), Y, X --> select (trunc nsw X to i1), Y, 0
   Value *Trunc;
+  auto Zero = [&]() { return ConstantInt::get(SelType, 0); };
+  auto One = [&]() { return ConstantInt::get(SelType, 1); };
+  auto MinusOne = [&]() { return ConstantInt::getAllOnesValue(SelType); };
   if (match(CondVal, m_NUWTrunc(m_Value(Trunc)))) {
----------------
jlebar wrote:

Done, thank you!

https://github.com/llvm/llvm-project/pull/173704


More information about the llvm-commits mailing list