diff options
author | aqjune <aqjune@gmail.com> | 2019-11-07 01:12:17 +0900 |
---|---|---|
committer | Juneyoung Lee <aqjune@gmail.com> | 2019-11-12 12:13:26 +0900 |
commit | 4187cb138b1c8401a78ac2ea98466c750cce61cb (patch) | |
tree | 26537911ca77f9ea1a8678314138639fe933732a /llvm/lib/Analysis/InstructionSimplify.cpp | |
parent | 70193b21d18ba0e4f9b9f68918c71bd91a887246 (diff) | |
download | bcm5719-llvm-4187cb138b1c8401a78ac2ea98466c750cce61cb.tar.gz bcm5719-llvm-4187cb138b1c8401a78ac2ea98466c750cce61cb.zip |
Add InstCombine/InstructionSimplify support for Freeze Instruction
Summary:
- Add llvm::SimplifyFreezeInst
- Add InstCombiner::visitFreeze
- Add llvm tests
Reviewers: majnemer, sanjoy, reames, lebedev.ri, spatel
Reviewed By: reames, lebedev.ri
Subscribers: reames, lebedev.ri, filcab, regehr, trentxintong, llvm-commits
Differential Revision: https://reviews.llvm.org/D29013
Diffstat (limited to 'llvm/lib/Analysis/InstructionSimplify.cpp')
-rw-r--r-- | llvm/lib/Analysis/InstructionSimplify.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp index 83b767a8fd1..3ef8f9b0050 100644 --- a/llvm/lib/Analysis/InstructionSimplify.cpp +++ b/llvm/lib/Analysis/InstructionSimplify.cpp @@ -5241,6 +5241,19 @@ Value *llvm::SimplifyCall(CallBase *Call, const SimplifyQuery &Q) { return ConstantFoldCall(Call, F, ConstantArgs, Q.TLI); } +/// Given operands for a Freeze, see if we can fold the result. +static Value *SimplifyFreezeInst(Value *Op0) { + // Use a utility function defined in ValueTracking. + if (llvm::isGuaranteedNotToBeUndefOrPoison(Op0)) + return Op0; + // We have room for improvement. + return nullptr; +} + +Value *llvm::SimplifyFreezeInst(Value *Op0, const SimplifyQuery &Q) { + return ::SimplifyFreezeInst(Op0); +} + /// See if we can compute a simplified version of this instruction. /// If not, this returns null. @@ -5383,6 +5396,9 @@ Value *llvm::SimplifyInstruction(Instruction *I, const SimplifyQuery &SQ, Result = SimplifyCall(cast<CallInst>(I), Q); break; } + case Instruction::Freeze: + Result = SimplifyFreezeInst(I->getOperand(0), Q); + break; #define HANDLE_CAST_INST(num, opc, clas) case Instruction::opc: #include "llvm/IR/Instruction.def" #undef HANDLE_CAST_INST |