Skip to content
Snippets Groups Projects
Commit f409fd65 authored by Alessandro Di Federico's avatar Alessandro Di Federico
Browse files

`OSR::constant()`: consider `Base` and `Factor`

`OSR::constant()` used to forward the result of
`BoundedValue::constant()`, but this is wrong, since the factor and the
base value have to be considered too.
parent bddc0d03
No related branches found
No related tags found
No related merge requests found
......@@ -447,7 +447,15 @@ public:
BV(Other.BV) { }
uint64_t constant() const {
return BV->constant();
using CE = llvm::ConstantExpr;
using CI = llvm::ConstantInt;
using Constant = llvm::Constant;
llvm::Type *T = BV->value()->getType();
Constant *ConstantC = CI::get(T, BV->constant());
Constant *FactorC = CI::get(T, Factor);
Constant *BaseC = CI::get(T, Base);
return getLimitedValue(CE::getAdd(CE::getMul(ConstantC, FactorC), BaseC));
}
/// \brief Combine this OSR with \p Operand through \p Opcode
......@@ -515,6 +523,7 @@ public:
const llvm::DataLayout &DL,
llvm::Type *Int64);
// TODO: are we sure we want to use Int64 here?
/// \brief Compute `a + b * Value`
llvm::Constant *evaluate(llvm::Constant *Value,
llvm::Type *Int64) const;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment