[PATCH] D63705: [ConstantFolding] Use hasVectorInstrinsicScalarOpd. NFC

Bjorn Pettersson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 24 05:07:34 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL364178: [ConstantFolding] Use hasVectorInstrinsicScalarOpd. NFC (authored by bjope, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D63705?vs=206167&id=206195#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63705/new/

https://reviews.llvm.org/D63705

Files:
  llvm/trunk/lib/Analysis/ConstantFolding.cpp


Index: llvm/trunk/lib/Analysis/ConstantFolding.cpp
===================================================================
--- llvm/trunk/lib/Analysis/ConstantFolding.cpp
+++ llvm/trunk/lib/Analysis/ConstantFolding.cpp
@@ -25,6 +25,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Analysis/TargetLibraryInfo.h"
 #include "llvm/Analysis/ValueTracking.h"
+#include "llvm/Analysis/VectorUtils.h"
 #include "llvm/Config/config.h"
 #include "llvm/IR/Constant.h"
 #include "llvm/IR/Constants.h"
@@ -1649,7 +1650,8 @@
   return false;
 }
 
-static Constant *ConstantFoldScalarCall1(StringRef Name, unsigned IntrinsicID,
+static Constant *ConstantFoldScalarCall1(StringRef Name,
+                                         Intrinsic::ID IntrinsicID,
                                          Type *Ty,
                                          ArrayRef<Constant *> Operands,
                                          const TargetLibraryInfo *TLI,
@@ -1943,7 +1945,8 @@
   return nullptr;
 }
 
-static Constant *ConstantFoldScalarCall2(StringRef Name, unsigned IntrinsicID,
+static Constant *ConstantFoldScalarCall2(StringRef Name,
+                                         Intrinsic::ID IntrinsicID,
                                          Type *Ty,
                                          ArrayRef<Constant *> Operands,
                                          const TargetLibraryInfo *TLI,
@@ -2172,7 +2175,8 @@
   return nullptr;
 }
 
-static Constant *ConstantFoldScalarCall3(StringRef Name, unsigned IntrinsicID,
+static Constant *ConstantFoldScalarCall3(StringRef Name,
+                                         Intrinsic::ID IntrinsicID,
                                          Type *Ty,
                                          ArrayRef<Constant *> Operands,
                                          const TargetLibraryInfo *TLI,
@@ -2270,7 +2274,8 @@
   return nullptr;
 }
 
-static Constant *ConstantFoldScalarCall(StringRef Name, unsigned IntrinsicID,
+static Constant *ConstantFoldScalarCall(StringRef Name,
+                                        Intrinsic::ID IntrinsicID,
                                         Type *Ty,
                                         ArrayRef<Constant *> Operands,
                                         const TargetLibraryInfo *TLI,
@@ -2287,7 +2292,8 @@
   return nullptr;
 }
 
-static Constant *ConstantFoldVectorCall(StringRef Name, unsigned IntrinsicID,
+static Constant *ConstantFoldVectorCall(StringRef Name,
+                                        Intrinsic::ID IntrinsicID,
                                         VectorType *VTy,
                                         ArrayRef<Constant *> Operands,
                                         const DataLayout &DL,
@@ -2339,17 +2345,8 @@
   for (unsigned I = 0, E = VTy->getNumElements(); I != E; ++I) {
     // Gather a column of constants.
     for (unsigned J = 0, JE = Operands.size(); J != JE; ++J) {
-      // These intrinsics use a scalar type for their second argument.
-      if (J == 1 &&
-          (IntrinsicID == Intrinsic::cttz || IntrinsicID == Intrinsic::ctlz ||
-           IntrinsicID == Intrinsic::powi)) {
-        Lane[J] = Operands[J];
-        continue;
-      }
-      // These intrinsics use a scalar type for their third argument.
-      if (J == 2 &&
-          (IntrinsicID == Intrinsic::smul_fix ||
-           IntrinsicID == Intrinsic::smul_fix_sat)) {
+      // Some intrinsics use a scalar type for certain arguments.
+      if (hasVectorInstrinsicScalarOpd(IntrinsicID, J)) {
         Lane[J] = Operands[J];
         continue;
       }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63705.206195.patch
Type: text/x-patch
Size: 3579 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190624/9f16cbb8/attachment.bin>


More information about the llvm-commits mailing list