Skip to content

Commit a3e7df8

Browse files
Use isOneOrOneSplat and name IR test variables.
1 parent 63af232 commit a3e7df8

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5042,7 +5042,6 @@ static SDValue simplifyDivRem(SDNode *N, SelectionDAG &DAG) {
50425042

50435043
unsigned Opc = N->getOpcode();
50445044
bool IsDiv = (ISD::SDIV == Opc) || (ISD::UDIV == Opc);
5045-
ConstantSDNode *N1C = isConstOrConstSplat(N1, false, true);
50465045

50475046
// X / undef -> undef
50485047
// X % undef -> undef
@@ -5074,7 +5073,7 @@ static SDValue simplifyDivRem(SDNode *N, SelectionDAG &DAG) {
50745073
// division-by-zero or remainder-by-zero, so assume the divisor is 1.
50755074
// TODO: Similarly, if we're zero-extending a boolean divisor, then assume
50765075
// it's a 1.
5077-
if ((N1C && N1C->isOne()) || (VT.getScalarType() == MVT::i1))
5076+
if (isOneOrOneSplat(N1) || (VT.getScalarType() == MVT::i1))
50785077
return IsDiv ? N0 : DAG.getConstant(0, DL, VT);
50795078

50805079
return SDValue();

llvm/test/CodeGen/AArch64/combine-sdiv.ll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1855,7 +1855,7 @@ define <16 x i16> @combine_vec_sdiv_by_one_obfuscated(<16 x i16> %x) "target-fea
18551855
; CHECK-GI-NEXT: mov v2.h[7], w10
18561856
; CHECK-GI-NEXT: mov v1.16b, v2.16b
18571857
; CHECK-GI-NEXT: ret
1858-
%1 = shufflevector <16 x i16> zeroinitializer, <16 x i16> splat (i16 1), <16 x i32> <i32 0, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31>
1859-
%2 = sdiv <16 x i16> %x, %1
1860-
ret <16 x i16> %2
1858+
%zero_and_ones = shufflevector <16 x i16> zeroinitializer, <16 x i16> splat (i16 1), <16 x i32> <i32 0, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31>
1859+
%div = sdiv <16 x i16> %x, %zero_and_ones
1860+
ret <16 x i16> %div
18611861
}

0 commit comments

Comments
 (0)