forked from OSchip/llvm-project
[ConstantFolding] Do not remove side effect from constrained functions
According to the discussion in https://reviews.llvm.org/D110322 the code that removes side effect from replaced function call is deleted. Differential Revision: https://reviews.llvm.org/D115870
This commit is contained in:
parent
9db0e21660
commit
77b923d0db
|
@ -1778,15 +1778,8 @@ static bool mayFoldConstrained(ConstrainedFPIntrinsic *CI,
|
|||
|
||||
// If the operation does not change exception status flags, it is safe
|
||||
// to fold.
|
||||
if (St == APFloat::opStatus::opOK) {
|
||||
// When FP exceptions are not ignored, intrinsic call will not be
|
||||
// eliminated, because it is considered as having side effect. But we
|
||||
// know that its evaluation does not raise exceptions, so side effect
|
||||
// is absent. To allow removing the call, mark it as not accessing memory.
|
||||
if (EB && *EB != fp::ExceptionBehavior::ebIgnore)
|
||||
CI->addFnAttr(Attribute::ReadNone);
|
||||
if (St == APFloat::opStatus::opOK)
|
||||
return true;
|
||||
}
|
||||
|
||||
// If evaluation raised FP exception, the result can depend on rounding
|
||||
// mode. If the latter is unknown, folding is not possible.
|
||||
|
|
|
@ -282,6 +282,7 @@ entry:
|
|||
define double @fadd_05() #0 {
|
||||
; CHECK-LABEL: @fadd_05(
|
||||
; CHECK-NEXT: entry:
|
||||
; CHECK-NEXT: [[RESULT:%.*]] = call double @llvm.experimental.constrained.fadd.f64(double 1.000000e+00, double 2.000000e+00, metadata !"round.tonearest", metadata !"fpexcept.strict") #[[ATTR0]]
|
||||
; CHECK-NEXT: ret double 3.000000e+00
|
||||
;
|
||||
entry:
|
||||
|
@ -293,6 +294,7 @@ entry:
|
|||
define double @fadd_06() #0 {
|
||||
; CHECK-LABEL: @fadd_06(
|
||||
; CHECK-NEXT: entry:
|
||||
; CHECK-NEXT: [[RESULT:%.*]] = call double @llvm.experimental.constrained.fadd.f64(double 1.000000e+00, double 2.000000e+00, metadata !"round.dynamic", metadata !"fpexcept.strict") #[[ATTR0]]
|
||||
; CHECK-NEXT: ret double 3.000000e+00
|
||||
;
|
||||
entry:
|
||||
|
|
|
@ -12,6 +12,7 @@ define float @fdiv_constant_fold() #0 {
|
|||
|
||||
define float @fdiv_constant_fold_strict() #0 {
|
||||
; CHECK-LABEL: @fdiv_constant_fold_strict(
|
||||
; CHECK-NEXT: [[F:%.*]] = call float @llvm.experimental.constrained.fdiv.f32(float 3.000000e+00, float 2.000000e+00, metadata !"round.tonearest", metadata !"fpexcept.strict") #[[ATTR0:[0-9]+]]
|
||||
; CHECK-NEXT: ret float 1.500000e+00
|
||||
;
|
||||
%f = call float @llvm.experimental.constrained.fdiv.f32(float 3.0, float 2.0, metadata !"round.tonearest", metadata !"fpexcept.strict") #0
|
||||
|
@ -21,7 +22,7 @@ define float @fdiv_constant_fold_strict() #0 {
|
|||
|
||||
define float @fdiv_constant_fold_strict2() #0 {
|
||||
; CHECK-LABEL: @fdiv_constant_fold_strict2(
|
||||
; CHECK-NEXT: [[F:%.*]] = call float @llvm.experimental.constrained.fdiv.f32(float 2.000000e+00, float 3.000000e+00, metadata !"round.tonearest", metadata !"fpexcept.strict") #[[ATTR0:[0-9]+]]
|
||||
; CHECK-NEXT: [[F:%.*]] = call float @llvm.experimental.constrained.fdiv.f32(float 2.000000e+00, float 3.000000e+00, metadata !"round.tonearest", metadata !"fpexcept.strict") #[[ATTR0]]
|
||||
; CHECK-NEXT: ret float [[F]]
|
||||
;
|
||||
%f = call float @llvm.experimental.constrained.fdiv.f32(float 2.0, float 3.0, metadata !"round.tonearest", metadata !"fpexcept.strict") #0
|
||||
|
@ -39,6 +40,7 @@ define float @frem_constant_fold() #0 {
|
|||
|
||||
define float @frem_constant_fold_strict() #0 {
|
||||
; CHECK-LABEL: @frem_constant_fold_strict(
|
||||
; CHECK-NEXT: [[F:%.*]] = call float @llvm.experimental.constrained.frem.f32(float 3.000000e+00, float 2.000000e+00, metadata !"round.tonearest", metadata !"fpexcept.strict") #[[ATTR0]]
|
||||
; CHECK-NEXT: ret float 1.000000e+00
|
||||
;
|
||||
%f = call float @llvm.experimental.constrained.frem.f32(float 3.0, float 2.0, metadata !"round.tonearest", metadata !"fpexcept.strict") #0
|
||||
|
|
|
@ -363,6 +363,7 @@ define float @fold_fadd_qnan_qnan_ebmaytrap() #0 {
|
|||
|
||||
define float @fold_fadd_qnan_qnan_ebstrict() #0 {
|
||||
; CHECK-LABEL: @fold_fadd_qnan_qnan_ebstrict(
|
||||
; CHECK-NEXT: [[ADD:%.*]] = call float @llvm.experimental.constrained.fadd.f32(float 0x7FF8000000000000, float 0x7FF8000000000000, metadata !"round.tonearest", metadata !"fpexcept.strict") #[[ATTR0]]
|
||||
; CHECK-NEXT: ret float 0x7FF8000000000000
|
||||
;
|
||||
%add = call float @llvm.experimental.constrained.fadd.f32(float 0x7ff8000000000000, float 0x7ff8000000000000, metadata !"round.tonearest", metadata !"fpexcept.strict") #0
|
||||
|
|
Loading…
Reference in New Issue