aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/Constants.cpp
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@sifive.com>2023-04-04 09:00:37 -0700
committerCraig Topper <craig.topper@sifive.com>2023-04-04 09:01:08 -0700
commit64ad6ead1f5839dc6920295d00ec8b16ea118f4a (patch)
treefbe7a649b01da72a230c0fb13e120fd3acc2ecc8 /llvm/lib/IR/Constants.cpp
parent8dad7f495302b5f2cd186dcc1cdd76874c80958a (diff)
downloadllvm-64ad6ead1f5839dc6920295d00ec8b16ea118f4a.zip
llvm-64ad6ead1f5839dc6920295d00ec8b16ea118f4a.tar.gz
llvm-64ad6ead1f5839dc6920295d00ec8b16ea118f4a.tar.bz2
[IR] Remove uses of the oddly named ConstantFP::getZeroValueForNegation in integer code.
Confusingly ConstantFP's getZeroValueForNegation intentionally handles non-FP constants. It calls getNullValue in Constant. Nearly all uses in tree are for integers rather than FP. Maybe due to replacing FSub -0.0, X idiom with an FNeg instructions a few years ago. This patch replaces all the integer uses in tree with ConstantInt::get(0, Ty). The one remaining use is in clang with a FIXME that it should use fneg. I'll fix that next and then delete ConstantFP::getZeroValueForNegation. Reviewed By: nikic Differential Revision: https://reviews.llvm.org/D147492
Diffstat (limited to 'llvm/lib/IR/Constants.cpp')
-rw-r--r--llvm/lib/IR/Constants.cpp3
1 files changed, 1 insertions, 2 deletions
diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp
index a4b00d9..9e26d6c 100644
--- a/llvm/lib/IR/Constants.cpp
+++ b/llvm/lib/IR/Constants.cpp
@@ -2601,8 +2601,7 @@ Constant *ConstantExpr::getShuffleVector(Constant *V1, Constant *V2,
Constant *ConstantExpr::getNeg(Constant *C, bool HasNUW, bool HasNSW) {
assert(C->getType()->isIntOrIntVectorTy() &&
"Cannot NEG a nonintegral value!");
- return getSub(ConstantFP::getZeroValueForNegation(C->getType()),
- C, HasNUW, HasNSW);
+ return getSub(ConstantInt::get(C->getType(), 0), C, HasNUW, HasNSW);
}
Constant *ConstantExpr::getNot(Constant *C) {