mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-28 12:16:09 +00:00
Fix UnitTests/2004-02-02-NegativeZero.c, which regressed when
I broke negate of FP values. llvm-svn: 107019
This commit is contained in:
parent
18bcf76f05
commit
c1028f689e
@ -1224,8 +1224,12 @@ Value *ScalarExprEmitter::VisitUnaryMinus(const UnaryOperator *E) {
|
|||||||
TestAndClearIgnoreResultAssign();
|
TestAndClearIgnoreResultAssign();
|
||||||
// Emit unary minus with EmitSub so we handle overflow cases etc.
|
// Emit unary minus with EmitSub so we handle overflow cases etc.
|
||||||
BinOpInfo BinOp;
|
BinOpInfo BinOp;
|
||||||
BinOp.RHS = Visit(E->getSubExpr());;
|
BinOp.RHS = Visit(E->getSubExpr());
|
||||||
BinOp.LHS = llvm::Constant::getNullValue(BinOp.RHS->getType());
|
|
||||||
|
if (BinOp.RHS->getType()->isFPOrFPVectorTy())
|
||||||
|
BinOp.LHS = llvm::ConstantFP::getZeroValueForNegation(BinOp.RHS->getType());
|
||||||
|
else
|
||||||
|
BinOp.LHS = llvm::Constant::getNullValue(BinOp.RHS->getType());
|
||||||
BinOp.Ty = E->getType();
|
BinOp.Ty = E->getType();
|
||||||
BinOp.Opcode = BinaryOperator::Sub;
|
BinOp.Opcode = BinaryOperator::Sub;
|
||||||
BinOp.E = E;
|
BinOp.E = E;
|
||||||
|
@ -137,3 +137,10 @@ int f12() {
|
|||||||
// CHECK: ret i32 1
|
// CHECK: ret i32 1
|
||||||
return 1||1;
|
return 1||1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Make sure negate of fp uses -0.0 for proper -0 handling.
|
||||||
|
double f13(double X) {
|
||||||
|
// CHECK: define double @f13
|
||||||
|
// CHECK: fsub double -0.000000e+00, %tmp
|
||||||
|
return -X;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user