@@ -15928,11 +15928,20 @@ static SDValue getVectorBitwiseReduce(unsigned Opcode, SDValue Vec, EVT VT,
15928
15928
return getVectorBitwiseReduce(Opcode, HalfVec, VT, DL, DAG);
15929
15929
}
15930
15930
15931
- // Vectors that are less than 64 bits get widened to neatly fit a 64 bit
15932
- // register, so e.g. <4 x i1> gets lowered to <4 x i16>. Sign extending to
15933
- // this element size leads to the best codegen, since e.g. setcc results
15934
- // might need to be truncated otherwise.
15935
- EVT ExtendedVT = MVT::getIntegerVT(std::max(64u / NumElems, 8u));
15931
+ // Results of setcc operations get widened to 128 bits if their input
15932
+ // operands are 128 bits wide and in case of reduce_and and reduce_or have
15933
+ // at least 4 elements, otherwise vectors that are less than 64 bits get
15934
+ // widened to neatly fit a 64 bit register, so e.g. <4 x i1> gets lowered to
15935
+ // either <4 x i16> or <4 x i32>. Sign extending to this element size leads
15936
+ // to the best codegen, since e.g. setcc results might need to be truncated
15937
+ // otherwise.
15938
+ unsigned ExtendedWidth = 64;
15939
+ if ((ScalarOpcode == ISD::XOR || NumElems >= 4) &&
15940
+ Vec.getOpcode() == ISD::SETCC &&
15941
+ Vec.getOperand(0).getValueSizeInBits() >= 128) {
15942
+ ExtendedWidth = 128;
15943
+ }
15944
+ EVT ExtendedVT = MVT::getIntegerVT(std::max(ExtendedWidth / NumElems, 8u));
15936
15945
15937
15946
// any_ext doesn't work with umin/umax, so only use it for uadd.
15938
15947
unsigned ExtendOp =
0 commit comments