summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2015-11-20 22:34:48 +0000
committerOwen Anderson <resistor@mac.com>2015-11-20 22:34:48 +0000
commit8e85130bb976c28ee0672586c2decaf315e9d153 (patch)
tree7cd60024ec7bae550c3dedc208c03edd724e9323 /llvm
parent5256fcada0ae3021b30bd1edc064beeffd0e41fc (diff)
downloadbcm5719-llvm-8e85130bb976c28ee0672586c2decaf315e9d153.tar.gz
bcm5719-llvm-8e85130bb976c28ee0672586c2decaf315e9d153.zip
Fix another infinite loop in Reassociate caused by Constant::isZero().
Not all zero vectors are ConstantDataVector's. llvm-svn: 253723
Diffstat (limited to 'llvm')
-rw-r--r--llvm/lib/IR/Constants.cpp10
-rw-r--r--llvm/test/Transforms/Reassociate/fp-expr.ll13
2 files changed, 23 insertions, 0 deletions
diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp
index b237c913dcf..d79fb3e7b0b 100644
--- a/llvm/lib/IR/Constants.cpp
+++ b/llvm/lib/IR/Constants.cpp
@@ -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();
}
diff --git a/llvm/test/Transforms/Reassociate/fp-expr.ll b/llvm/test/Transforms/Reassociate/fp-expr.ll
index ee927069812..5af3b1991c9 100644
--- a/llvm/test/Transforms/Reassociate/fp-expr.ll
+++ b/llvm/test/Transforms/Reassociate/fp-expr.ll
@@ -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()
OpenPOWER on IntegriCloud