@@ -963,14 +963,14 @@ SDOperand DAGCombiner::visitAND(SDNode *N) {
963
963
DAG.getConstant (N1C->getValue ()&N01C->getValue (), VT));
964
964
}
965
965
// fold (and (sign_extend_inreg x, i16 to i32), 1) -> (and x, 1)
966
- if (N0.getOpcode () == ISD::SIGN_EXTEND_INREG) {
966
+ if (N1C && N0.getOpcode () == ISD::SIGN_EXTEND_INREG) {
967
967
unsigned ExtendBits =
968
968
MVT::getSizeInBits (cast<VTSDNode>(N0.getOperand (1 ))->getVT ());
969
- if ((N1C->getValue () & (~0ULL << ExtendBits)) == 0 )
969
+ if (ExtendBits == 64 || (N1C->getValue () & (~0ULL << ExtendBits) == 0 ) )
970
970
return DAG.getNode (ISD::AND, VT, N0.getOperand (0 ), N1);
971
971
}
972
972
// fold (and (or x, 0xFFFF), 0xFF) -> 0xFF
973
- if (N0.getOpcode () == ISD::OR && N1C )
973
+ if (N1C && N0.getOpcode () == ISD::OR)
974
974
if (ConstantSDNode *ORI = dyn_cast<ConstantSDNode>(N0.getOperand (1 )))
975
975
if ((ORI->getValue () & N1C->getValue ()) == N1C->getValue ())
976
976
return N1;
@@ -1031,7 +1031,7 @@ SDOperand DAGCombiner::visitAND(SDNode *N) {
1031
1031
return DAG.getNode (N0.getOpcode (), VT, ANDNode, N0.getOperand (1 ));
1032
1032
}
1033
1033
// fold (and (sra)) -> (and (srl)) when possible.
1034
- if (N0.getOpcode () == ISD::SRA && N0.Val ->hasOneUse ())
1034
+ if (N0.getOpcode () == ISD::SRA && N0.Val ->hasOneUse ()) {
1035
1035
if (ConstantSDNode *N01C = dyn_cast<ConstantSDNode>(N0.getOperand (1 ))) {
1036
1036
// If the RHS of the AND has zeros where the sign bits of the SRA will
1037
1037
// land, turn the SRA into an SRL.
@@ -1043,7 +1043,7 @@ SDOperand DAGCombiner::visitAND(SDNode *N) {
1043
1043
return SDOperand ();
1044
1044
}
1045
1045
}
1046
-
1046
+ }
1047
1047
// fold (zext_inreg (extload x)) -> (zextload x)
1048
1048
if (N0.getOpcode () == ISD::EXTLOAD) {
1049
1049
MVT::ValueType EVT = cast<VTSDNode>(N0.getOperand (3 ))->getVT ();
0 commit comments