summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorLang Hames <lhames@gmail.com>2012-04-24 18:58:36 +0000
committerLang Hames <lhames@gmail.com>2012-04-24 18:58:36 +0000
commit84531c2b5f749543fa236c78eae49a5928064283 (patch)
tree3d7f6d106d71e621e9e05531f36616a0b6aaf90f /llvm/lib
parentaacb8a5809eaef4c2dccbb8aa34157310662fc8b (diff)
downloadbcm5719-llvm-84531c2b5f749543fa236c78eae49a5928064283.tar.gz
bcm5719-llvm-84531c2b5f749543fa236c78eae49a5928064283.zip
Add support for llvm.arm.neon.vmull* intrinsics to InstCombine. This fixes
<rdar://problem/11291436>. llvm-svn: 155468
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
index 77e47271008..5ad9382e3cc 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -14,6 +14,7 @@
#include "InstCombine.h"
#include "llvm/Support/CallSite.h"
#include "llvm/Target/TargetData.h"
+#include "llvm/Analysis/InstructionSimplify.h"
#include "llvm/Analysis/MemoryBuiltins.h"
#include "llvm/Transforms/Utils/BuildLibCalls.h"
#include "llvm/Transforms/Utils/Local.h"
@@ -694,6 +695,40 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) {
break;
}
+ case Intrinsic::arm_neon_vmulls:
+ case Intrinsic::arm_neon_vmullu: {
+ // Zext/sext intrinsic operands according to the intrinsic type, then try to
+ // simplify them. This lets us try a SimplifyMulInst on the extended
+ // operands. If the zext/sext instructions are unused when we're done then
+ // delete them from the block.
+ Value* Arg0 = II->getArgOperand(0);
+ Value* Arg1 = II->getArgOperand(1);
+ bool Zext = (II->getIntrinsicID() == Intrinsic::arm_neon_vmullu);
+ Instruction *Arg0W =
+ Zext ? CastInst::CreateZExtOrBitCast(Arg0, II->getType(), "", II) :
+ CastInst::CreateSExtOrBitCast(Arg0, II->getType(), "", II);
+ Value* Arg0WS = SimplifyInstruction(Arg0W);
+ if (Arg0WS == 0) // If simplification fails just pass through the ext'd val.
+ Arg0WS = Arg0W;
+ Instruction *Arg1W =
+ Zext ? CastInst::CreateZExtOrBitCast(Arg1, II->getType(), "", II) :
+ CastInst::CreateSExtOrBitCast(Arg1, II->getType(), "", II);
+ Value* Arg1WS = SimplifyInstruction(Arg1W);
+ if (Arg1WS == 0)
+ Arg1WS = Arg1W;
+ Instruction *SimplifiedInst = 0;
+ if (Value* V = SimplifyMulInst(Arg0WS, Arg1WS, TD)) {
+ SimplifiedInst = ReplaceInstUsesWith(CI, V);
+ }
+ if (Arg0W->use_empty())
+ Arg0W->eraseFromParent();
+ if (Arg1W->use_empty())
+ Arg1W->eraseFromParent();
+ if (SimplifiedInst != 0)
+ return SimplifiedInst;
+ break;
+ }
+
case Intrinsic::stackrestore: {
// If the save is right next to the restore, remove the restore. This can
// happen when variable allocas are DCE'd.
OpenPOWER on IntegriCloud