Skip to content

Commit 831c877

Browse files
committed
ValueTracking: address review
1 parent 0e9d014 commit 831c877

File tree

4 files changed

+7
-9
lines changed

4 files changed

+7
-9
lines changed

llvm/include/llvm/Analysis/ValueTracking.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -791,9 +791,9 @@ bool onlyUsedByLifetimeMarkers(const Value *V);
791791
/// droppable instructions.
792792
bool onlyUsedByLifetimeMarkersOrDroppableInsts(const Value *V);
793793

794-
/// Return true if the instruction is known to be a vector lane-wise operation
795-
/// i.e. if it doesn't potentially cross vector lanes.
796-
bool isLanewiseOperation(const Instruction *I);
794+
/// Return true if the instruction doesn't potentially cross vector lanes. This
795+
/// is useful to make GVN-replacements for vector types.
796+
bool isNotCrossLaneOperation(const Instruction *I);
797797

798798
/// Return true if the instruction does not have any effects besides
799799
/// calculating the result and does not have undefined behavior.

llvm/lib/Analysis/InstructionSimplify.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4343,7 +4343,7 @@ static Value *simplifyWithOpReplaced(Value *V, Value *Op, Value *RepOp,
43434343
if (isa<PHINode>(I))
43444344
return nullptr;
43454345

4346-
if (Op->getType()->isVectorTy() && !isLanewiseOperation(I))
4346+
if (Op->getType()->isVectorTy() && !isNotCrossLaneOperation(I))
43474347
// For vector types, the simplification must hold per-lane, so forbid
43484348
// potentially cross-lane operations like shufflevector.
43494349
return nullptr;

llvm/lib/Analysis/ValueTracking.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6947,7 +6947,7 @@ bool llvm::onlyUsedByLifetimeMarkersOrDroppableInsts(const Value *V) {
69476947
V, /* AllowLifetime */ true, /* AllowDroppable */ true);
69486948
}
69496949

6950-
bool llvm::isLanewiseOperation(const Instruction *I) {
6950+
bool llvm::isNotCrossLaneOperation(const Instruction *I) {
69516951
if (auto *II = dyn_cast<IntrinsicInst>(I)) {
69526952
switch (II->getIntrinsicID()) {
69536953
// TODO: expand this list.
@@ -6967,9 +6967,7 @@ bool llvm::isLanewiseOperation(const Instruction *I) {
69676967
return false;
69686968
}
69696969
}
6970-
auto *Shuffle = dyn_cast<ShuffleVectorInst>(I);
6971-
return (!Shuffle || Shuffle->isSelect()) &&
6972-
!isa<CallBase, BitCastInst, ExtractElementInst>(I);
6970+
return !isa<CallBase, BitCastInst, ShuffleVectorInst, ExtractElementInst>(I);
69736971
}
69746972

69756973
bool llvm::isSafeToSpeculativelyExecute(const Instruction *Inst,

llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3630,7 +3630,7 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
36303630
// * The select condition is not a vector, or the intrinsic does not
36313631
// perform cross-lane operations.
36323632
if (isSafeToSpeculativelyExecuteWithVariableReplaced(&CI) &&
3633-
isLanewiseOperation(II))
3633+
isNotCrossLaneOperation(II))
36343634
for (Value *Op : II->args())
36353635
if (auto *Sel = dyn_cast<SelectInst>(Op))
36363636
if (Instruction *R = FoldOpIntoSelect(*II, Sel))

0 commit comments

Comments
 (0)