Details
Diff Detail
Event Timeline
llvm/lib/Analysis/ValueTracking.cpp | ||
---|---|---|
4369 | We're in the default FP environment here since we're looking at FAdd and FSub instructions. The check for FAdd isn't needed? |
Also handle sub
llvm/lib/Analysis/ValueTracking.cpp | ||
---|---|---|
4369 | I was just copying from CannotBeNegativeZero but I guess we can improve on it at the same time |
llvm/lib/Analysis/ValueTracking.cpp | ||
---|---|---|
4369 | As I understand it, with default rounding the only addition that can return -0 is -0 + -0. So if either operand is known not to be -0, the result cannot be -0. And the only subtraction that can return -0 is -0 - +0. |
llvm/lib/Analysis/ValueTracking.cpp | ||
---|---|---|
4369 | Checking what instcombine thinks, define float @fsub_p0_p0(float %arg0) { %sub = fsub float 0.0, 0.0 ret float %sub } define float @fsub_n0_n0(float %arg0) { %sub = fsub float -0.0, -0.0 ret float %sub } define float @fsub_p0_n0(float %arg0) { %sub = fsub float 0.0, -0.0 ret float %sub } define float @fsub_n0_p0(float %arg0) { %sub = fsub float -0.0, 0.0 ret float %sub } define float @fsub_p0_p0(float %arg0) { ret float 0.000000e+00 } define float @fsub_n0_n0(float %arg0) { ret float 0.000000e+00 } define float @fsub_p0_n0(float %arg0) { ret float 0.000000e+00 } define float @fsub_n0_p0(float %arg0) { ret float -0.000000e+00 } The missing optimization we could do here is check if DAZ is enabled and also cover denormal inputs |
llvm/lib/Analysis/ValueTracking.cpp | ||
---|---|---|
4369 | First, this is wrong for FSub, since -0 - +0 = -0 Second, you can generalize KnownRHS.KnownFPClasses == fcPosZero to KnownRHS.isKnownNot(fcNegZero) (or fcPosZero for FSub). Third you could do a similar check on the LHS. For both FAdd and FSub, if the LHS is not -0 then the result can't be -0. |
llvm/include/llvm/Analysis/ValueTracking.h | ||
---|---|---|
281 ↗ | (On Diff #515550) | Matter of taste I guess, but I don't think a helper function this simple actually helps. |
llvm/lib/Analysis/ValueTracking.cpp | ||
3879–3880 | Could use inputDenormalIsIEEEOrPosZero here. | |
3884 | This doesn't work. If denormal mode is PosZero then a denormal can be flushed to +0, so this function should return false. |
ping
llvm/include/llvm/Analysis/ValueTracking.h | ||
---|---|---|
281 ↗ | (On Diff #515550) | Mostly for consistency with the others |
LGTM
llvm/lib/Analysis/ValueTracking.cpp | ||
---|---|---|
3888 | Nit: might as well push this into the PositiveZero/default case. |
llvm/lib/Analysis/ValueTracking.cpp | ||
---|---|---|
3888 | That wouldn't short circuit the attribute parsing |
Could use inputDenormalIsIEEEOrPosZero here.