Index: llvm/lib/Analysis/InstructionSimplify.cpp =================================================================== --- llvm/lib/Analysis/InstructionSimplify.cpp +++ llvm/lib/Analysis/InstructionSimplify.cpp @@ -4725,6 +4725,13 @@ } } + // (X | Y) ? 0 : X --> 0 (commuted 2 ways) + ICmpInst::Predicate Pred; + if (match(Cond, + m_ICmp(Pred, m_c_Or(m_Specific(FalseVal), m_Value()), m_Zero())) && + match(TrueVal, m_ZeroInt()) && Pred == ICmpInst::ICMP_NE) + return TrueVal; + // select ?, X, X -> X if (TrueVal == FalseVal) return TrueVal; Index: llvm/test/Transforms/InstSimplify/select.ll =================================================================== --- llvm/test/Transforms/InstSimplify/select.ll +++ llvm/test/Transforms/InstSimplify/select.ll @@ -1404,3 +1404,13 @@ %cond = select <2 x i1> %tobool.not, <2 x i32> %mul, <2 x i32> zeroinitializer ret <2 x i32> %cond } + +define i32 @select_icmp_or(i32 noundef %a, i32 noundef %b) { +; CHECK-LABEL: @select_icmp_or( +; CHECK-NEXT: ret i32 0 +; + %or = or i32 %a, %b + %tobool = icmp ne i32 %or, 0 + %cond = select i1 %tobool, i32 0, i32 %a + ret i32 %cond +}