[llvm] [SimplifyCFG] Handle trunc condition in foldBranchToCommonDest. (PR #135490)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 13 23:27:13 PDT 2025


dtcxzyw wrote:

> > So shall I revert it? do I understand correct that it is not the optimization that is slow but it generates a slower binary
> 
> Yes, it generates a slower binary, at least in terms of instructions retired. I think part of the problem here may be that a lot of targets seem to treat all truncates as free? https://llvm.godbolt.org/z/49Tq8qEqe So they don't count towards the bonus inst threshold. A trunc i1 without nuw should have the same cost as an and 1, I think.

I thought this patch would reduce the number of branches. Perhaps we can adjust `foldBranchToCommonDest` to only handle `trunc nuw %x to i1`.


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


More information about the llvm-commits mailing list