Fix another infinite loop in Reassociate caused by Constant::isZero().

Not all zero vectors are ConstantDataVector's.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253723 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Owen Anderson 2015-11-20 22:34:48 +00:00
parent 2d2aadfa70
commit 108258ac78
2 changed files with 23 additions and 0 deletions

View File

@ -53,6 +53,11 @@ bool Constant::isNegativeZeroValue() const {
if (SplatCFP && SplatCFP->isZero() && SplatCFP->isNegative())
return true;
if (const ConstantVector *CV = dyn_cast<ConstantVector>(this))
if (ConstantFP *SplatCFP = dyn_cast_or_null<ConstantFP>(CV->getSplatValue()))
if (SplatCFP && SplatCFP->isZero() && SplatCFP->isNegative())
return true;
// We've already handled true FP case; any other FP vectors can't represent -0.0.
if (getType()->isFPOrFPVectorTy())
return false;
@ -74,6 +79,11 @@ bool Constant::isZeroValue() const {
if (SplatCFP && SplatCFP->isZero())
return true;
if (const ConstantVector *CV = dyn_cast<ConstantVector>(this))
if (ConstantFP *SplatCFP = dyn_cast_or_null<ConstantFP>(CV->getSplatValue()))
if (SplatCFP && SplatCFP->isZero())
return true;
// Otherwise, just use +0.0.
return isNullValue();
}

View File

@ -12,6 +12,19 @@ define void @test1() {
ret void
}
define half @test2() {
; CHECK-LABEL: @test2
; CHECK: fsub
; CHECK: fsub
; CHECK: fadd
%tmp15 = fsub fast half undef, undef
%tmp17 = fsub fast half undef, %tmp15
%tmp18 = fadd fast half undef, %tmp17
ret half %tmp18
}
; Function Attrs: optsize
declare <4 x float> @blam()