[InstCombine] Remove the undef-related workaround code in visitSelectInst
This patch removes an old hack in visitSelectInst that was written to avoid miscompilation bugs in loop unswitch. (Added via https://reviews.llvm.org/D35811) The legacy loop unswitch pass will be removed after D124376, and the new simple loop unswitch pass correctly uses freeze to avoid introducing UB after D124252. Since the hack is not necessary anymore, this patch removes it. Reviewed By: nikic Differential Revision: https://reviews.llvm.org/D124426
This commit is contained in:
parent
112e3d8687
commit
40a2e35599
|
@ -2644,22 +2644,6 @@ Instruction *InstCombinerImpl::visitSelectInst(SelectInst &SI) {
|
|||
Value *FalseVal = SI.getFalseValue();
|
||||
Type *SelType = SI.getType();
|
||||
|
||||
// FIXME: Remove this workaround when freeze related patches are done.
|
||||
// For select with undef operand which feeds into an equality comparison,
|
||||
// don't simplify it so loop unswitch can know the equality comparison
|
||||
// may have an undef operand. This is a workaround for PR31652 caused by
|
||||
// descrepancy about branch on undef between LoopUnswitch and GVN.
|
||||
if (match(TrueVal, m_Undef()) || match(FalseVal, m_Undef())) {
|
||||
if (llvm::any_of(SI.users(), [&](User *U) {
|
||||
ICmpInst *CI = dyn_cast<ICmpInst>(U);
|
||||
if (CI && CI->isEquality())
|
||||
return true;
|
||||
return false;
|
||||
})) {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
if (Value *V = SimplifySelectInst(CondVal, TrueVal, FalseVal,
|
||||
SQ.getWithInstruction(&SI)))
|
||||
return replaceInstUsesWith(SI, V);
|
||||
|
|
|
@ -3,8 +3,7 @@
|
|||
|
||||
define i1 @f(i1 %cond, i32 %x, i32 %x2) {
|
||||
; CHECK-LABEL: @f(
|
||||
; CHECK-NEXT: [[Y:%.*]] = select i1 [[COND:%.*]], i32 poison, i32 [[X:%.*]]
|
||||
; CHECK-NEXT: [[C:%.*]] = icmp eq i32 [[Y]], [[X2:%.*]]
|
||||
; CHECK-NEXT: [[C:%.*]] = icmp eq i32 [[X:%.*]], [[X2:%.*]]
|
||||
; CHECK-NEXT: ret i1 [[C]]
|
||||
;
|
||||
%y = select i1 %cond, i32 poison, i32 %x
|
||||
|
|
Loading…
Reference in New Issue