[PATCH] D13076: [InstCombine] transform masking off of an FP sign bit into a fabs() intrinsic call (PR24886)

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 24 13:37:23 PDT 2015

spatel marked 2 inline comments as done.

Comment at: lib/Transforms/InstCombine/InstCombineAndOrXor.cpp:1471
@@ -1470,2 +1470,3 @@
   // fold (and (cast A), (cast B)) -> (cast (and A, B))
+  if (CastInst *Op0C = dyn_cast<CastInst>(Op0)) {
sanjoy wrote:
> I think this comment should now be sunk to the inner if.
Yes - fixed.

Comment at: lib/Transforms/InstCombine/InstCombineAndOrXor.cpp:1507
@@ +1506,3 @@
+    // The backend should know how to optimize fabs().
+    // TODO: This transform should also apply to vectors.
+    ConstantInt *CI;
sanjoy wrote:
> Is this optimization valid if the cast is actually an `fptosi` or `fptoui`?  They're also `CastInst`s.
No, it should only fire on a bitcast. 
Thanks for catching that! I've added an additional check and test case to make sure we're not altering an fptoui.


More information about the llvm-commits mailing list