This helps handling a case where the BUILD_VECTOR has i16 element type and i32 constant operands t2: v8i16 = setcc t8, t17, setult:ch t3: v8i16 = BUILD_VECTOR Constant:i32<1>, ... t4: v8i16 = and t2, t3 t5: v8i16 = add t8, t4 This can be turned into t5: v8i16 = sub t8, t2, and allows us to remove t3 and t4 from the DAG.
|15425 ↗||(On Diff #435362)|
Declare Known on the line where it is assigned.
KnownBits Known = DAG.computeKnownBits...
|15432 ↗||(On Diff #435362)|
This is no inconsistent with the other call to computeKnownBits. I think for both you can do DAG.computeKnownBits(LHS) or DAG.computeKnownBits(RHS).
This shoudl have been picked up by foldAddSubMasked1 in the generic DAG combiner but wasn't because the BUILD_VECTOR has i8 element type and i32 constant operands. We should fix that to not require the widths to match.
Are all of the callers of isOneOrOneSplat ok with this change?
Is this change correct for the caller you’re interested in if the element type of the build_vector is i1?
Let me go through the callers one by one. There are 8 uses of isOneOrOneSplat in llvm, all in DAGCombiner.cpp.
so far, I ran through check-llvm and looks good.
This comment can probably go - unlike Null/AllOnes this isn't going to work well if the bitcast is to a vector type with different scalar sizes