[llvm] r358913 - [InstSimplify] Move masked.gather w/no active lanes handling to InstSimplify from InstCombine

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 22 12:30:01 PDT 2019


Author: reames
Date: Mon Apr 22 12:30:01 2019
New Revision: 358913

URL: http://llvm.org/viewvc/llvm-project?rev=358913&view=rev
Log:
[InstSimplify] Move masked.gather w/no active lanes handling to InstSimplify from InstCombine

In the process, use the existing masked.load combine which is slightly stronger, and handles a mix of zero and undef elements in the mask.  


Modified:
    llvm/trunk/lib/Analysis/InstructionSimplify.cpp
    llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp

Modified: llvm/trunk/lib/Analysis/InstructionSimplify.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InstructionSimplify.cpp?rev=358913&r1=358912&r2=358913&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/InstructionSimplify.cpp (original)
+++ llvm/trunk/lib/Analysis/InstructionSimplify.cpp Mon Apr 22 12:30:01 2019
@@ -4876,7 +4876,8 @@ static Value *simplifyIntrinsic(Function
 
   // Handle intrinsics with 3 or more arguments.
   switch (IID) {
-  case Intrinsic::masked_load: {
+  case Intrinsic::masked_load:
+  case Intrinsic::masked_gather: {
     Value *MaskArg = ArgBegin[2];
     Value *PassthruArg = ArgBegin[3];
     // If the mask is all zeros or undef, the "passthru" argument is the result.

Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp?rev=358913&r1=358912&r2=358913&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp Mon Apr 22 12:30:01 2019
@@ -1220,11 +1220,6 @@ Instruction *InstCombiner::simplifyMaske
 // * Vector splat address w/known mask -> scalar load
 // * Vector incrementing address -> vector masked load
 static Instruction *simplifyMaskedGather(IntrinsicInst &II, InstCombiner &IC) {
-  // If the mask is all zeros, return the "passthru" argument of the gather.
-  auto *ConstMask = dyn_cast<Constant>(II.getArgOperand(2));
-  if (ConstMask && ConstMask->isNullValue())
-    return IC.replaceInstUsesWith(II, II.getArgOperand(3));
-
   return nullptr;
 }
 




More information about the llvm-commits mailing list