[ConstantExpr] Remove fneg expression

As part of https://discourse.llvm.org/t/rfc-remove-most-constant-expressions/63179,
this removes the fneg constant expression (which is, incidentally,
the only unary operator expression).

Differential Revision: https://reviews.llvm.org/D133418
This commit is contained in:
Nikita Popov
2022-09-07 11:36:19 +02:00
parent 6247988e07
commit 96cb7c2273
15 changed files with 53 additions and 118 deletions

View File

@@ -1385,10 +1385,15 @@ static bool isConstExprSupported(uint8_t Opcode) {
if (Opcode >= BitcodeConstant::FirstSpecialOpcode)
return true;
// If -expand-constant-exprs is set, we want to consider all expressions
// as unsupported.
if (ExpandConstantExprs)
return false;
if (Instruction::isBinaryOp(Opcode))
return ConstantExpr::isSupportedBinOp(Opcode);
return !ExpandConstantExprs;
return Opcode != Instruction::FNeg;
}
Expected<Value *> BitcodeReader::materializeValue(unsigned StartValID,
@@ -1449,8 +1454,6 @@ Expected<Value *> BitcodeReader::materializeValue(unsigned StartValID,
C = UpgradeBitCastExpr(BC->Opcode, ConstOps[0], BC->getType());
if (!C)
C = ConstantExpr::getCast(BC->Opcode, ConstOps[0], BC->getType());
} else if (Instruction::isUnaryOp(BC->Opcode)) {
C = ConstantExpr::get(BC->Opcode, ConstOps[0], BC->Flags);
} else if (Instruction::isBinaryOp(BC->Opcode)) {
C = ConstantExpr::get(BC->Opcode, ConstOps[0], ConstOps[1], BC->Flags);
} else {