[PATCH] D52324: Allow select patterns to work on vectors in more places

Thomas Lively via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 20 14:26:20 PDT 2018


tlively created this revision.
tlively added reviewers: aheejin, dschuff.
Herald added subscribers: llvm-commits, sunfish.

This CL allows constant vectors of floats to be recognized as non-NaN
and non-zero in select patterns. This change makes
`matchSelectPattern` more powerful generally, but was motivated
specifically because I wanted fminnan and fmaxnan to be created for
vector versions of the scalar patterns they are created for.

Tested with check-all on all targets. A testcase in the WebAssembly
backend that tests the non-nan codepath is in an upcoming CL.


Repository:
  rL LLVM

https://reviews.llvm.org/D52324

Files:
  lib/Analysis/ValueTracking.cpp


Index: lib/Analysis/ValueTracking.cpp
===================================================================
--- lib/Analysis/ValueTracking.cpp
+++ lib/Analysis/ValueTracking.cpp
@@ -4365,14 +4365,14 @@
   if (FMF.noNaNs())
     return true;
 
-  if (auto *C = dyn_cast<ConstantFP>(V))
-    return !C->isNaN();
+  if (auto *C = dyn_cast<Constant>(V))
+    return C->getType()->isFPOrFPVectorTy() && !C->isNaN();
   return false;
 }
 
 static bool isKnownNonZero(const Value *V) {
-  if (auto *C = dyn_cast<ConstantFP>(V))
-    return !C->isZero();
+  if (auto *C = dyn_cast<Constant>(V))
+    return C->getType()->isFPOrFPVectorTy() && !C->isZeroValue();
   return false;
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52324.166363.patch
Type: text/x-patch
Size: 674 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180920/eb6cbb5e/attachment.bin>


More information about the llvm-commits mailing list