[llvm] r290704 - [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.
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 28 19:30:17 PST 2016
Author: ctopper
Date: Wed Dec 28 21:30:17 2016
New Revision: 290704
URL: http://llvm.org/viewvc/llvm-project?rev=290704&view=rev
Log:
[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.
Modified:
llvm/trunk/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp?rev=290704&r1=290703&r2=290704&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp Wed Dec 28 21:30:17 2016
@@ -1261,8 +1261,10 @@ Value *InstCombiner::SimplifyDemandedVec
// 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::SimplifyDemandedVec
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::SimplifyDemandedVec
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::SimplifyDemandedVec
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::SimplifyDemandedVec
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::SimplifyDemandedVec
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;
More information about the llvm-commits
mailing list