[PATCH] D50714: [InstCombine] Fold Select with binary op - FP opcodes

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 21 07:54:20 PDT 2018


spatel added inline comments.


================
Comment at: lib/Transforms/InstCombine/InstCombineSelect.cpp:72-73
+    IsEq = true;
+  else if (Pred == FCmpInst::FCMP_ONE)
+    IsEq = false;
+  else
----------------
xbolva00 wrote:
> spatel wrote:
> > Did you try testing ONE/UNE in alive-fp?
> ```
> %A = fcmp one float %x, 0.0
> %B = fadd nsz float %x, %z
> %C = select i1 %A, float %B, float %y
> =>
> %C = select i1 %A, float %B, float %z
> ----------                                                                      
>   %A = fcmp one float %x, 0.0
>   %B = fadd nsz float %x, %z
>   %C = select %A, float %B, float %y
> =>
>   %C = select %A, float %B, float %z
> 
> ERROR: Mismatch in values for float %C                                          
> 
> Example:
> float %x = NaN
>    i1 %A = 0x0 (0)
> float %z = 0.0640411376953125*(2**-126)
> float %B = NaN
> float %y = 1.00048828125*(2**1)
> source: 1.00048828125*(2**1)
> target: 0.0640411376953125*(2**-126)
> 
> xbolva00 at xbolva00:~/alive-nj$ ./run.py                               
> [Reading from terminal...]
> %A = fcmp une float %x, 0.0
> %B = fadd nsz float %x, %z
> %C = select i1 %A, float %B, float %y
> =>
> %C = select i1 %A, float %B, float %z
> ----------                                                                      
>   %A = fcmp une float %x, 0.0
>   %B = fadd nsz float %x, %z
>   %C = select %A, float %B, float %y
> =>
>   %C = select %A, float %B, float %z
> 
> ERROR: Mismatch in values for float %C                                          
> 
> Example:
> float %x = = +0.0
>    i1 %A = 0x0 (0)
> float %z = NaN
> float %B = NaN
> float %y = 0.0000002384185791015625*(2**-126)
> source: 0.0000002384185791015625*(2**-126)
> target: NaN
> 
> ```
I think you want these tests to use -0.0 because that's the identity constant for fadd.


https://reviews.llvm.org/D50714





More information about the llvm-commits mailing list