Skip to content

Commit c044f13

Browse files
committed
Allow shifting instead of masks if the types are legal.
1 parent bf34b2e commit c044f13

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

llvm/include/llvm/CodeGen/TargetLowering.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -839,8 +839,11 @@ class LLVM_ABI TargetLoweringBase {
839839
/// Return true if the variant with 2 variable shifts is preferred.
840840
/// Return false if there is no preference.
841841
virtual bool shouldFoldMaskToVariableShiftPair(SDValue X) const {
842-
// By default, let's assume that no one prefers shifts.
843-
return false;
842+
// By default, let's assume that no one prefers shifts for vectors
843+
EVT VT = X.getValueType();
844+
845+
// Prefer shifts for legal types
846+
return isOperationLegal(ISD::SHL, VT);
844847
}
845848

846849
/// Return true if it is profitable to fold a pair of shifts into a mask.

0 commit comments

Comments
 (0)