forked from OSchip/llvm-project
[InstCombine] propagate fast-math-flags when folding fcmp+fneg, part 2
llvm-svn: 346238
This commit is contained in:
parent
b3fbba6d15
commit
2fd5b0ebfb
|
@ -5467,9 +5467,10 @@ Instruction *InstCombiner::visitFCmpInst(FCmpInst &I) {
|
|||
Value *X, *Y;
|
||||
if (match(Op0, m_FNeg(m_Value(X)))) {
|
||||
if (match(Op1, m_FNeg(m_Value(Y)))) {
|
||||
// FIXME: Drops FMF.
|
||||
// fcmp pred (fneg X), (fneg Y) -> fcmp swap(pred) X, Y
|
||||
return new FCmpInst(I.getSwappedPredicate(), X, Y);
|
||||
Instruction *NewFCmp = new FCmpInst(I.getSwappedPredicate(), X, Y);
|
||||
NewFCmp->copyFastMathFlags(&I);
|
||||
return NewFCmp;
|
||||
}
|
||||
|
||||
Constant *C;
|
||||
|
|
|
@ -104,7 +104,7 @@ define <2 x i1> @fcmp_fneg_fmf_vec(<2 x float> %x) {
|
|||
|
||||
define i1 @fneg_fneg_swap_pred(float %x, float %y) {
|
||||
; CHECK-LABEL: @fneg_fneg_swap_pred(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = fcmp ogt float [[X:%.*]], [[Y:%.*]]
|
||||
; CHECK-NEXT: [[CMP:%.*]] = fcmp nnan ogt float [[X:%.*]], [[Y:%.*]]
|
||||
; CHECK-NEXT: ret i1 [[CMP]]
|
||||
;
|
||||
%neg1 = fsub float -0.0, %x
|
||||
|
@ -115,7 +115,7 @@ define i1 @fneg_fneg_swap_pred(float %x, float %y) {
|
|||
|
||||
define <2 x i1> @fneg_fneg_swap_pred_vec(<2 x float> %x, <2 x float> %y) {
|
||||
; CHECK-LABEL: @fneg_fneg_swap_pred_vec(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = fcmp ogt <2 x float> [[X:%.*]], [[Y:%.*]]
|
||||
; CHECK-NEXT: [[CMP:%.*]] = fcmp ninf ogt <2 x float> [[X:%.*]], [[Y:%.*]]
|
||||
; CHECK-NEXT: ret <2 x i1> [[CMP]]
|
||||
;
|
||||
%neg1 = fsub <2 x float> <float -0.0, float -0.0>, %x
|
||||
|
|
Loading…
Reference in New Issue