New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect transformation: (llvm.maximum undef, %x) -> undef #46911
Comments
Transformation in alive2: https://alive2.llvm.org/ce/z/7ef9X7 |
I guess we can make it |
Sorry, I pasted the wrong code. The test case in the Description is correct. Here's the buggy one (from Transforms/InstSimplify/floating-point-arithmetic.ll): define <2 x double> @maximum_nan_op0_vec(<2 x double> %x) { |
Alive2 thinks so :), https://alive2.llvm.org/ce/z/Pzdatp |
I'm not sure if it's better, but we are trying to return NAN (rather than the variable operand) in that test, and that should be correct: So we matched the partially-defined constant as a NAN, we just failed to propagate the fully-defined NAN from that. |
I also see that constant folding isn't fully implemented for any 2-operand FP intrinsics, so at minimum we have some inconsistent behavior (not sure if there are any miscompiles). |
looks even better :) |
mentioned in issue #47292 |
Extended Description
Test case from Transforms/InstSimplify/floating-point-arithmetic.ll
define <2 x double> @maxnum_nan_op0_vec(<2 x double> %x) {
; CHECK-LABEL: @maxnum_nan_op0_vec(
; CHECK-NEXT: ret <2 x double> [[X:%.*]]
;
%r = call <2 x double> @llvm.maxnum.v2f64(<2 x double> <double 0x7ff8000000000000, double undef>, <2 x double> %x)
ret <2 x double> %r
}
The second lane for this case performs the rewrite (llvm.maximum undef, %x) -> undef. The rewrite is illegal. The domain for (llvm.maximum undef, %x) depends on %x, and obviously the result of llvm.maximum does not fully cover the range of undef in most of cases.
The text was updated successfully, but these errors were encountered: