Value *Op0, *Op1;
if (!match(&I, m_LogicalOp(m_Value(Op0), m_Value(Op1))))
return false;
+
+ // If this logic op has not been simplified yet, just bail out and let that
+ // happen first. Otherwise, the code below may wrongly invert.
+ if (Op0 == Op1)
+ return false;
+
Instruction::BinaryOps NewOpc =
match(&I, m_LogicalAnd()) ? Instruction::Or : Instruction::And;
bool IsBinaryOp = isa<BinaryOperator>(I);
ret i1 %i4
}
-; FIXME: This is a miscompile.
+; This would miscompile by not handling the unsimplified select correctly.
define i1 @PR59704(i1 %c, i1 %b, i64 %arg) {
; CHECK-LABEL: @PR59704(
; CHECK-NEXT: entry:
; CHECK-NEXT: br i1 [[C:%.*]], label [[IF:%.*]], label [[JOIN:%.*]]
; CHECK: if:
+; CHECK-NEXT: [[CMP_NOT:%.*]] = icmp eq i64 [[ARG:%.*]], 0
; CHECK-NEXT: br label [[JOIN]]
; CHECK: join:
-; CHECK-NEXT: ret i1 true
+; CHECK-NEXT: [[PHI:%.*]] = phi i1 [ true, [[ENTRY:%.*]] ], [ [[CMP_NOT]], [[IF]] ]
+; CHECK-NEXT: ret i1 [[PHI]]
;
entry:
br i1 %c, label %if, label %join