[ValueTracking] Fix incorrect handling of canCreateUndefOrPoison

.. in isGuaranteedNotToBeUndefOrPoison.

This caused early exit of isGuaranteedNotToBeUndefOrPoison, making it return
imprecise result.

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D84251
This commit is contained in:
Juneyoung Lee 2020-07-22 09:30:42 +09:00
parent 18581fd2c4
commit ace0bf7490
2 changed files with 18 additions and 4 deletions

View File

@ -4824,10 +4824,7 @@ bool llvm::isGuaranteedNotToBeUndefOrPoison(const Value *V,
return true;
}
if (canCreateUndefOrPoison(Opr))
return false;
if (all_of(Opr->operands(), OpCheck))
if (!canCreateUndefOrPoison(Opr) && all_of(Opr->operands(), OpCheck))
return true;
}

View File

@ -381,6 +381,23 @@ EXIT:
ret i32 %fr2
}
declare i32 @any_num()
define i32 @brcond_call() {
; CHECK-LABEL: @brcond_call(
; CHECK-NEXT: [[X:%.*]] = call i32 @any_num()
; CHECK-NEXT: switch i32 [[X]], label [[EXIT:%.*]] [
; CHECK-NEXT: ]
; CHECK: EXIT:
; CHECK-NEXT: ret i32 [[X]]
;
%x = call i32 @any_num()
switch i32 %x, label %EXIT []
EXIT:
%y = freeze i32 %x
ret i32 %y
}
define i1 @brcond_noopt(i1 %c, i1 %c2) {
; CHECK-LABEL: @brcond_noopt(
; CHECK-NEXT: [[F:%.*]] = freeze i1 [[C:%.*]]