forked from OSchip/llvm-project
[LoopVectorizer] Enable support for floating-point subtraction reductions
llvm-svn: 215200
This commit is contained in:
parent
3feea9c11a
commit
65b08f5e46
|
@ -5136,7 +5136,7 @@ LoopVectorizationLegality::isReductionInstr(Instruction *I,
|
||||||
ReductionKind Kind,
|
ReductionKind Kind,
|
||||||
ReductionInstDesc &Prev) {
|
ReductionInstDesc &Prev) {
|
||||||
bool FP = I->getType()->isFloatingPointTy();
|
bool FP = I->getType()->isFloatingPointTy();
|
||||||
bool FastMath = (FP && I->isCommutative() && I->isAssociative());
|
bool FastMath = FP && I->hasUnsafeAlgebra();
|
||||||
switch (I->getOpcode()) {
|
switch (I->getOpcode()) {
|
||||||
default:
|
default:
|
||||||
return ReductionInstDesc(false, I);
|
return ReductionInstDesc(false, I);
|
||||||
|
@ -5158,6 +5158,7 @@ LoopVectorizationLegality::isReductionInstr(Instruction *I,
|
||||||
return ReductionInstDesc(Kind == RK_IntegerXor, I);
|
return ReductionInstDesc(Kind == RK_IntegerXor, I);
|
||||||
case Instruction::FMul:
|
case Instruction::FMul:
|
||||||
return ReductionInstDesc(Kind == RK_FloatMult && FastMath, I);
|
return ReductionInstDesc(Kind == RK_FloatMult && FastMath, I);
|
||||||
|
case Instruction::FSub:
|
||||||
case Instruction::FAdd:
|
case Instruction::FAdd:
|
||||||
return ReductionInstDesc(Kind == RK_FloatAdd && FastMath, I);
|
return ReductionInstDesc(Kind == RK_FloatAdd && FastMath, I);
|
||||||
case Instruction::FCmp:
|
case Instruction::FCmp:
|
||||||
|
|
|
@ -23,3 +23,25 @@ for.body: ; preds = %for.body, %entry
|
||||||
for.end: ; preds = %for.body
|
for.end: ; preds = %for.body
|
||||||
ret float %add
|
ret float %add
|
||||||
}
|
}
|
||||||
|
|
||||||
|
;CHECK-LABEL: @foosub(
|
||||||
|
;CHECK: fsub fast <4 x float>
|
||||||
|
;CHECK: ret
|
||||||
|
define float @foosub(float* nocapture %A, i32* nocapture %n) nounwind uwtable readonly ssp {
|
||||||
|
entry:
|
||||||
|
br label %for.body
|
||||||
|
|
||||||
|
for.body: ; preds = %for.body, %entry
|
||||||
|
%indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
|
||||||
|
%sum.04 = phi float [ 0.000000e+00, %entry ], [ %sub, %for.body ]
|
||||||
|
%arrayidx = getelementptr inbounds float* %A, i64 %indvars.iv
|
||||||
|
%0 = load float* %arrayidx, align 4
|
||||||
|
%sub = fsub fast float %sum.04, %0
|
||||||
|
%indvars.iv.next = add i64 %indvars.iv, 1
|
||||||
|
%lftr.wideiv = trunc i64 %indvars.iv.next to i32
|
||||||
|
%exitcond = icmp eq i32 %lftr.wideiv, 200
|
||||||
|
br i1 %exitcond, label %for.end, label %for.body
|
||||||
|
|
||||||
|
for.end: ; preds = %for.body
|
||||||
|
ret float %sub
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue