Files
clang-p2996/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
Craig Topper 11e92bd61f [SelectionDAG] Improve codegen for udiv by constant if any divisors are 1.
If the divisor is 1, the magic algorithm does not return a correct
result and we end up using a select to pick the numerator for those
elements at the end.

Therefore we can use undef for that element of the earlier operations
when the divisor is 1. We sometimes get this through SimplifyDemandedVectorElts,
but not always. Definitely seems like we don't if the NPQ fixup is used.

Unfortunately, DAGCombiner is unable to fold srl X, <0, undef> to X so
I had to add flags to avoid emitting the srl unless one of the shift
amounts is non-zero.

Reviewed By: lebedev.ri

Differential Revision: https://reviews.llvm.org/D141022
2023-01-05 08:41:44 -08:00

414 KiB