@@ -9904,15 +9904,35 @@ void Lowering::ContainCheckHWIntrinsic(GenTreeHWIntrinsic* node)
9904
9904
// because it will prevent other transforms that will be better for codegen.
9905
9905
9906
9906
LIR::Use use;
9907
-
9908
- if ((oper == GT_XOR) && isEmbeddedBroadcastCompatible && BlockRange ().TryGetUse (node, &use) &&
9909
- use.User ()->OperIsVectorFusedMultiplyOp ())
9907
+ if (isEmbeddedBroadcastCompatible && BlockRange ().TryGetUse (node, &use))
9910
9908
{
9911
- // xor is bitwise and the actual xor node might be a different base type
9912
- // from the FMA node, so we check if its negative zero using the FMA base
9913
- // type since that's what the end negation would end up using
9914
- var_types fmaSimdBaseType = use.User ()->AsHWIntrinsic ()->GetSimdBaseType ();
9915
- isEmbeddedBroadcastCompatible = !containedOperand->IsVectorNegativeZero (fmaSimdBaseType);
9909
+ if ((oper == GT_XOR) && use.User ()->OperIsVectorFusedMultiplyOp ())
9910
+ {
9911
+ // xor is bitwise and the actual xor node might be a different base type
9912
+ // from the FMA node, so we check if its negative zero using the FMA base
9913
+ // type since that's what the end negation would end up using
9914
+ var_types fmaSimdBaseType = use.User ()->AsHWIntrinsic ()->GetSimdBaseType ();
9915
+ isEmbeddedBroadcastCompatible =
9916
+ !containedOperand->IsVectorNegativeZero (fmaSimdBaseType);
9917
+ }
9918
+ else if (((oper == GT_AND) || (oper == GT_AND_NOT)) && use.User ()->OperIsHWIntrinsic ())
9919
+ {
9920
+ // For EQ/NE(AND(X, CnsVec), ZeroVector) we don't need to fold CnsVec into a contained
9921
+ // broadcast operand - AND will be folded into TestZ anyway.
9922
+ GenTreeHWIntrinsic* userHw = use.User ()->AsHWIntrinsic ();
9923
+ NamedIntrinsic userId = userHw->GetHWIntrinsicId ();
9924
+
9925
+ bool isEQ = (userId == NI_Vector128_op_Equality) ||
9926
+ (userId == NI_Vector256_op_Equality) ||
9927
+ (userId == NI_Vector512_op_Equality);
9928
+ bool isNE = (userId == NI_Vector128_op_Inequality) ||
9929
+ (userId == NI_Vector256_op_Inequality) ||
9930
+ (userId == NI_Vector512_op_Inequality);
9931
+ if ((isEQ || isNE) && (userHw->Op (1 )->IsVectorZero () || userHw->Op (2 )->IsVectorZero ()))
9932
+ {
9933
+ isEmbeddedBroadcastCompatible = false ;
9934
+ }
9935
+ }
9916
9936
}
9917
9937
9918
9938
if (isEmbeddedBroadcastCompatible)
0 commit comments