diff options
author | Craig Topper <craig.topper@gmail.com> | 2016-12-29 03:30:17 +0000 |
---|---|---|
committer | Craig Topper <craig.topper@gmail.com> | 2016-12-29 03:30:17 +0000 |
commit | 1a8a3377cced3b73b9b7038545e60bcbd805edf7 (patch) | |
tree | 8b4547ae0a612361763041de77e90226a9d1cf82 /llvm/lib/Transforms/InstCombine | |
parent | d723804fa250a66d593678e7331c0bbb1ecaec79 (diff) | |
download | bcm5719-llvm-1a8a3377cced3b73b9b7038545e60bcbd805edf7.tar.gz bcm5719-llvm-1a8a3377cced3b73b9b7038545e60bcbd805edf7.zip |
[InstCombine][X86] If the lowest element of a scalar intrinsic isn't used make sure we add it to the worklist so we can DCE it sooner.
We bypassed the intrinsic and returned the passthru operand, but we should also add the intrinsic to the worklist since its now dead. This can allow DCE to find it sooner and remove it. Similar was done for InsertElement when the inserted element isn't demanded.
llvm-svn: 290704
Diffstat (limited to 'llvm/lib/Transforms/InstCombine')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp index 0738883be15..2fb569d54fa 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp @@ -1261,8 +1261,10 @@ Value *InstCombiner::SimplifyDemandedVectorElts(Value *V, APInt DemandedElts, // pass them through like other scalar intrinsics. So we shouldn't just // use Arg0 if DemandedElts[0] is clear like we do for other intrinsics. // Instead we should return a zero vector. - if (!DemandedElts[0]) + if (!DemandedElts[0]) { + Worklist.Add(II); return ConstantAggregateZero::get(II->getType()); + } // Only the lower element is used. DemandedElts = 1; @@ -1284,8 +1286,10 @@ Value *InstCombiner::SimplifyDemandedVectorElts(Value *V, APInt DemandedElts, if (TmpV) { II->setArgOperand(0, TmpV); MadeChange = true; } // If lowest element of a scalar op isn't used then use Arg0. - if (!DemandedElts[0]) + if (!DemandedElts[0]) { + Worklist.Add(II); return II->getArgOperand(0); + } // TODO: If only low elt lower SQRT to FSQRT (with rounding/exceptions // checks). break; @@ -1304,8 +1308,10 @@ Value *InstCombiner::SimplifyDemandedVectorElts(Value *V, APInt DemandedElts, if (TmpV) { II->setArgOperand(0, TmpV); MadeChange = true; } // If lowest element of a scalar op isn't used then use Arg0. - if (!DemandedElts[0]) + if (!DemandedElts[0]) { + Worklist.Add(II); return II->getArgOperand(0); + } // Only lower element is used for operand 1. DemandedElts = 1; @@ -1333,8 +1339,10 @@ Value *InstCombiner::SimplifyDemandedVectorElts(Value *V, APInt DemandedElts, if (TmpV) { II->setArgOperand(0, TmpV); MadeChange = true; } // If lowest element of a scalar op isn't used then use Arg0. - if (!DemandedElts[0]) + if (!DemandedElts[0]) { + Worklist.Add(II); return II->getArgOperand(0); + } // Only lower element is used for operand 1. DemandedElts = 1; @@ -1381,8 +1389,10 @@ Value *InstCombiner::SimplifyDemandedVectorElts(Value *V, APInt DemandedElts, if (TmpV) { II->setArgOperand(0, TmpV); MadeChange = true; } // If lowest element of a scalar op isn't used then use Arg0. - if (!DemandedElts[0]) + if (!DemandedElts[0]) { + Worklist.Add(II); return II->getArgOperand(0); + } // Only lower element is used for operand 1 and 2. DemandedElts = 1; @@ -1412,8 +1422,10 @@ Value *InstCombiner::SimplifyDemandedVectorElts(Value *V, APInt DemandedElts, if (TmpV) { II->setArgOperand(2, TmpV); MadeChange = true; } // If lowest element of a scalar op isn't used then use Arg2. - if (!DemandedElts[0]) + if (!DemandedElts[0]) { + Worklist.Add(II); return II->getArgOperand(2); + } // Only lower element is used for operand 0 and 1. DemandedElts = 1; |