[llvm] [ConstraintElim] Handle switch cases with the same destination (PR #76928)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 4 02:48:59 PST 2024


dtcxzyw wrote:

> I don't think this is a good fit for ConstraintElimination. I'd expect either IPSCCP or CVP to optimize such cases. If they don't, we should fix it there.

CVP already handle this.
https://github.com/llvm/llvm-project/blob/ce61b0e9a41fb55beaef04610967ccc7b69307f8/llvm/lib/Analysis/LazyValueInfo.cpp#L1428-L1475

However, it cannot fix the original issue because the condition of switch is `%bf.cast.i` but the value to compare is `%bf.clear.i`. So I fixed it in ConstraintElimination.
If we plan to fix it in CVP, we should make `LazyValueInfoImpl::getValueAt` recursive, which is more expensive than the approach of this patch.


https://github.com/llvm/llvm-project/pull/76928


More information about the llvm-commits mailing list