[llvm] [InstCombine] Do not require nsz for reassociating fmul (PR #93698)
Jay Foad via llvm-commits
llvm-commits at lists.llvm.org
Wed May 29 11:06:07 PDT 2024
jayfoad wrote:
Here's an Alive2 script to prove that reassociating multiplication of +/- 0 still gives the right result.
```
define float @src(i1 %ia, i1 %ib, i1 %ic) {
%fa = sitofp i1 %ia to float
%fb = sitofp i1 %ib to float
%fc = sitofp i1 %ic to float
; za, zb, zc are all +/-0
%za = fmul float %fa, 0.0
%zb = fmul float %fb, 0.0
%zc = fmul float %fc, 0.0
; (za * zb) * zc
%x = fmul float %za, %zb
%y = fmul float %x, %zc
ret float %y
}
define float @tgt(i1 %ia, i1 %ib, i1 %ic) {
%fa = sitofp i1 %ia to float
%fb = sitofp i1 %ib to float
%fc = sitofp i1 %ic to float
; za, zb, zc are all +/-0
%za = fmul float %fa, 0.0
%zb = fmul float %fb, 0.0
%zc = fmul float %fc, 0.0
; za * (zb * zc)
%x = fmul float %zb, %zc
%y = fmul float %za, %x
ret float %y
}
```
If I [try it online](https://alive2.llvm.org/ce/z/z5CCVV) I currently get "ERROR: SMT Error: invalid extract application". @nunoplopes @regehr is that an Alive2 bug?
https://github.com/llvm/llvm-project/pull/93698
More information about the llvm-commits
mailing list