mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-14 07:09:08 +00:00
[InstCombine] intersect FMF when reassociating FP min/max intrinsics
As discussed in PR45478: https://bugs.llvm.org/show_bug.cgi?id=45478 ...propagating FMF from the outer (second) call is not correct, so intersect them instead. I suspect we could do better (see TODO comment), but mismatched FMF is probably too rare to care about. Differential Revision: https://reviews.llvm.org/D78631
This commit is contained in:
parent
1e1b9f9ee4
commit
a8904ba965
@ -2298,8 +2298,11 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) {
|
|||||||
llvm_unreachable("unexpected intrinsic ID");
|
llvm_unreachable("unexpected intrinsic ID");
|
||||||
}
|
}
|
||||||
Instruction *NewCall = Builder.CreateBinaryIntrinsic(
|
Instruction *NewCall = Builder.CreateBinaryIntrinsic(
|
||||||
IID, X, ConstantFP::get(Arg0->getType(), Res));
|
IID, X, ConstantFP::get(Arg0->getType(), Res), II);
|
||||||
NewCall->copyIRFlags(II);
|
// TODO: Conservatively intersecting FMF. If Res == C2, the transform
|
||||||
|
// was a simplification (so Arg0 and its original flags could
|
||||||
|
// propagate?)
|
||||||
|
NewCall->andIRFlags(M);
|
||||||
return replaceInstUsesWith(*II, NewCall);
|
return replaceInstUsesWith(*II, NewCall);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -157,7 +157,7 @@ define float @maximum_f32_1_maximum_val_p0(float %x) {
|
|||||||
|
|
||||||
define float @maximum_f32_1_maximum_p0_val_fast(float %x) {
|
define float @maximum_f32_1_maximum_p0_val_fast(float %x) {
|
||||||
; CHECK-LABEL: @maximum_f32_1_maximum_p0_val_fast(
|
; CHECK-LABEL: @maximum_f32_1_maximum_p0_val_fast(
|
||||||
; CHECK-NEXT: [[TMP1:%.*]] = call fast float @llvm.maximum.f32(float [[X:%.*]], float 1.000000e+00)
|
; CHECK-NEXT: [[TMP1:%.*]] = call float @llvm.maximum.f32(float [[X:%.*]], float 1.000000e+00)
|
||||||
; CHECK-NEXT: ret float [[TMP1]]
|
; CHECK-NEXT: ret float [[TMP1]]
|
||||||
;
|
;
|
||||||
%y = call float @llvm.maximum.f32(float 0.0, float %x)
|
%y = call float @llvm.maximum.f32(float 0.0, float %x)
|
||||||
@ -167,7 +167,7 @@ define float @maximum_f32_1_maximum_p0_val_fast(float %x) {
|
|||||||
|
|
||||||
define float @maximum_f32_1_maximum_p0_val_fmf1(float %x) {
|
define float @maximum_f32_1_maximum_p0_val_fmf1(float %x) {
|
||||||
; CHECK-LABEL: @maximum_f32_1_maximum_p0_val_fmf1(
|
; CHECK-LABEL: @maximum_f32_1_maximum_p0_val_fmf1(
|
||||||
; CHECK-NEXT: [[TMP1:%.*]] = call nnan ninf arcp float @llvm.maximum.f32(float [[X:%.*]], float 1.000000e+00)
|
; CHECK-NEXT: [[TMP1:%.*]] = call nnan arcp float @llvm.maximum.f32(float [[X:%.*]], float 1.000000e+00)
|
||||||
; CHECK-NEXT: ret float [[TMP1]]
|
; CHECK-NEXT: ret float [[TMP1]]
|
||||||
;
|
;
|
||||||
%y = call arcp nnan float @llvm.maximum.f32(float 0.0, float %x)
|
%y = call arcp nnan float @llvm.maximum.f32(float 0.0, float %x)
|
||||||
@ -187,7 +187,7 @@ define float @maximum_f32_1_maximum_p0_val_fmf2(float %x) {
|
|||||||
|
|
||||||
define float @maximum_f32_1_maximum_p0_val_fmf3(float %x) {
|
define float @maximum_f32_1_maximum_p0_val_fmf3(float %x) {
|
||||||
; CHECK-LABEL: @maximum_f32_1_maximum_p0_val_fmf3(
|
; CHECK-LABEL: @maximum_f32_1_maximum_p0_val_fmf3(
|
||||||
; CHECK-NEXT: [[TMP1:%.*]] = call nnan ninf arcp float @llvm.maximum.f32(float [[X:%.*]], float 1.000000e+00)
|
; CHECK-NEXT: [[TMP1:%.*]] = call nnan ninf float @llvm.maximum.f32(float [[X:%.*]], float 1.000000e+00)
|
||||||
; CHECK-NEXT: ret float [[TMP1]]
|
; CHECK-NEXT: ret float [[TMP1]]
|
||||||
;
|
;
|
||||||
%y = call nnan ninf float @llvm.maximum.f32(float 0.0, float %x)
|
%y = call nnan ninf float @llvm.maximum.f32(float 0.0, float %x)
|
||||||
|
@ -157,7 +157,7 @@ define float @maxnum_f32_1_maxnum_val_p0(float %x) {
|
|||||||
|
|
||||||
define float @maxnum_f32_1_maxnum_p0_val_fast(float %x) {
|
define float @maxnum_f32_1_maxnum_p0_val_fast(float %x) {
|
||||||
; CHECK-LABEL: @maxnum_f32_1_maxnum_p0_val_fast(
|
; CHECK-LABEL: @maxnum_f32_1_maxnum_p0_val_fast(
|
||||||
; CHECK-NEXT: [[TMP1:%.*]] = call fast float @llvm.maxnum.f32(float [[X:%.*]], float 1.000000e+00)
|
; CHECK-NEXT: [[TMP1:%.*]] = call float @llvm.maxnum.f32(float [[X:%.*]], float 1.000000e+00)
|
||||||
; CHECK-NEXT: ret float [[TMP1]]
|
; CHECK-NEXT: ret float [[TMP1]]
|
||||||
;
|
;
|
||||||
%y = call float @llvm.maxnum.f32(float 0.0, float %x)
|
%y = call float @llvm.maxnum.f32(float 0.0, float %x)
|
||||||
@ -167,7 +167,7 @@ define float @maxnum_f32_1_maxnum_p0_val_fast(float %x) {
|
|||||||
|
|
||||||
define float @minnum_f32_1_maxnum_p0_val_fmf1(float %x) {
|
define float @minnum_f32_1_maxnum_p0_val_fmf1(float %x) {
|
||||||
; CHECK-LABEL: @minnum_f32_1_maxnum_p0_val_fmf1(
|
; CHECK-LABEL: @minnum_f32_1_maxnum_p0_val_fmf1(
|
||||||
; CHECK-NEXT: [[TMP1:%.*]] = call nnan ninf float @llvm.maxnum.f32(float [[X:%.*]], float 1.000000e+00)
|
; CHECK-NEXT: [[TMP1:%.*]] = call nnan float @llvm.maxnum.f32(float [[X:%.*]], float 1.000000e+00)
|
||||||
; CHECK-NEXT: ret float [[TMP1]]
|
; CHECK-NEXT: ret float [[TMP1]]
|
||||||
;
|
;
|
||||||
%y = call nnan float @llvm.maxnum.f32(float 0.0, float %x)
|
%y = call nnan float @llvm.maxnum.f32(float 0.0, float %x)
|
||||||
|
@ -159,7 +159,7 @@ define float @minimum_f32_1_minimum_val_p0(float %x) {
|
|||||||
|
|
||||||
define float @minimum_f32_1_minimum_p0_val_fast(float %x) {
|
define float @minimum_f32_1_minimum_p0_val_fast(float %x) {
|
||||||
; CHECK-LABEL: @minimum_f32_1_minimum_p0_val_fast(
|
; CHECK-LABEL: @minimum_f32_1_minimum_p0_val_fast(
|
||||||
; CHECK-NEXT: [[TMP1:%.*]] = call fast float @llvm.minimum.f32(float [[X:%.*]], float 0.000000e+00)
|
; CHECK-NEXT: [[TMP1:%.*]] = call float @llvm.minimum.f32(float [[X:%.*]], float 0.000000e+00)
|
||||||
; CHECK-NEXT: ret float [[TMP1]]
|
; CHECK-NEXT: ret float [[TMP1]]
|
||||||
;
|
;
|
||||||
%y = call float @llvm.minimum.f32(float 0.0, float %x)
|
%y = call float @llvm.minimum.f32(float 0.0, float %x)
|
||||||
@ -169,7 +169,7 @@ define float @minimum_f32_1_minimum_p0_val_fast(float %x) {
|
|||||||
|
|
||||||
define float @minimum_f32_1_minimum_p0_val_fmf1(float %x) {
|
define float @minimum_f32_1_minimum_p0_val_fmf1(float %x) {
|
||||||
; CHECK-LABEL: @minimum_f32_1_minimum_p0_val_fmf1(
|
; CHECK-LABEL: @minimum_f32_1_minimum_p0_val_fmf1(
|
||||||
; CHECK-NEXT: [[TMP1:%.*]] = call nnan ninf float @llvm.minimum.f32(float [[X:%.*]], float 0.000000e+00)
|
; CHECK-NEXT: [[TMP1:%.*]] = call float @llvm.minimum.f32(float [[X:%.*]], float 0.000000e+00)
|
||||||
; CHECK-NEXT: ret float [[TMP1]]
|
; CHECK-NEXT: ret float [[TMP1]]
|
||||||
;
|
;
|
||||||
%y = call float @llvm.minimum.f32(float 0.0, float %x)
|
%y = call float @llvm.minimum.f32(float 0.0, float %x)
|
||||||
|
@ -159,7 +159,7 @@ define float @minnum_f32_1_minnum_val_p0(float %x) {
|
|||||||
|
|
||||||
define float @minnum_f32_1_minnum_p0_val_fast(float %x) {
|
define float @minnum_f32_1_minnum_p0_val_fast(float %x) {
|
||||||
; CHECK-LABEL: @minnum_f32_1_minnum_p0_val_fast(
|
; CHECK-LABEL: @minnum_f32_1_minnum_p0_val_fast(
|
||||||
; CHECK-NEXT: [[TMP1:%.*]] = call fast float @llvm.minnum.f32(float [[X:%.*]], float 0.000000e+00)
|
; CHECK-NEXT: [[TMP1:%.*]] = call float @llvm.minnum.f32(float [[X:%.*]], float 0.000000e+00)
|
||||||
; CHECK-NEXT: ret float [[TMP1]]
|
; CHECK-NEXT: ret float [[TMP1]]
|
||||||
;
|
;
|
||||||
%y = call float @llvm.minnum.f32(float 0.0, float %x)
|
%y = call float @llvm.minnum.f32(float 0.0, float %x)
|
||||||
@ -169,7 +169,7 @@ define float @minnum_f32_1_minnum_p0_val_fast(float %x) {
|
|||||||
|
|
||||||
define float @minnum_f32_1_minnum_p0_val_fmf1(float %x) {
|
define float @minnum_f32_1_minnum_p0_val_fmf1(float %x) {
|
||||||
; CHECK-LABEL: @minnum_f32_1_minnum_p0_val_fmf1(
|
; CHECK-LABEL: @minnum_f32_1_minnum_p0_val_fmf1(
|
||||||
; CHECK-NEXT: [[TMP1:%.*]] = call nnan ninf float @llvm.minnum.f32(float [[X:%.*]], float 0.000000e+00)
|
; CHECK-NEXT: [[TMP1:%.*]] = call nnan float @llvm.minnum.f32(float [[X:%.*]], float 0.000000e+00)
|
||||||
; CHECK-NEXT: ret float [[TMP1]]
|
; CHECK-NEXT: ret float [[TMP1]]
|
||||||
;
|
;
|
||||||
%y = call nsz nnan float @llvm.minnum.f32(float 0.0, float %x)
|
%y = call nsz nnan float @llvm.minnum.f32(float 0.0, float %x)
|
||||||
@ -179,7 +179,7 @@ define float @minnum_f32_1_minnum_p0_val_fmf1(float %x) {
|
|||||||
|
|
||||||
define float @minnum_f32_1_minnum_p0_val_fmf2(float %x) {
|
define float @minnum_f32_1_minnum_p0_val_fmf2(float %x) {
|
||||||
; CHECK-LABEL: @minnum_f32_1_minnum_p0_val_fmf2(
|
; CHECK-LABEL: @minnum_f32_1_minnum_p0_val_fmf2(
|
||||||
; CHECK-NEXT: [[TMP1:%.*]] = call ninf nsz float @llvm.minnum.f32(float [[X:%.*]], float 0.000000e+00)
|
; CHECK-NEXT: [[TMP1:%.*]] = call ninf float @llvm.minnum.f32(float [[X:%.*]], float 0.000000e+00)
|
||||||
; CHECK-NEXT: ret float [[TMP1]]
|
; CHECK-NEXT: ret float [[TMP1]]
|
||||||
;
|
;
|
||||||
%y = call nnan ninf float @llvm.minnum.f32(float 0.0, float %x)
|
%y = call nnan ninf float @llvm.minnum.f32(float 0.0, float %x)
|
||||||
|
Loading…
Reference in New Issue
Block a user