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 of minnum with nnan flag #44823
Comments
assigned to @rotateright |
This is a reassociation transform in InstCombiner::visitCallInst(): It's propagating flags from the 2nd (outer) min/max, but needs to intersect them instead? Online version of Alive2 doesn't seem to know about minnum intrinsic: |
sorry, yes, this patch hasn't landed and I haven't setup our compiler explorer to use branches -- will update as soon as it lands |
Posting alive2 output if you're interested. define float @minnum_f32_1_minnum_p0_val_nnan_ninf(float %x) { Example: Source: Target: |
our compiler explorer supports this test case now: |
This also applies to Anyone has been working on it? If not, I'm glad to take this |
Sorry, I lost track of this bug. I have a draft somewhere that would intersect the flags. Let me clean that up and post for review. |
Alive2 (online version at least) doesn't recognize the related "minimum" and "maximum" intrinsics? declare float @llvm.maximum.f32(float, float) define float @src(float %x) { define float @tgt(float %x) { |
Hi Sanjay, These two are WIP and will be supported soon.
|
Should be fixed with: |
Extended Description
As stated in LangRef, if either operand for llvm.minnum is a NaN, returns the other non-NaN operand. If llvm.minnum is attached with nnan flag, when an argument is a NaN, it produces a poison value.
See below the incorrect transformation. When input %x is NaN, the source program returns 0.0, while the target program returns poison. Target is more poisonous than source.
llvm/test/Transforms/InstCombine/minnum.ll
define float @minnum_f32_1_minnum_p0_val_nnan_ninf(float %x) {
; CHECK-LABEL: @minnum_f32_1_minnum_p0_val_nnan_ninf(
; CHECK-NEXT: [[TMP1:%.]] = call nnan ninf float @llvm.minnum.f32(float [[X:%.]], float 0.000000e+00)
; CHECK-NEXT: ret float [[TMP1]]
;
%y = call float @llvm.minnum.f32(float 0.0, float %x)
%z = call nnan ninf float @llvm.minnum.f32(float %y, float 1.0)
ret float %z
}
The text was updated successfully, but these errors were encountered: