llvm-project
6a25e454 - [ConstantFolding] Support ptrtoaddr in ConstantFoldCompareInstOperands (#162653)

Commit
3 days ago
[ConstantFolding] Support ptrtoaddr in ConstantFoldCompareInstOperands (#162653) This folds `icmp (ptrtoaddr x, ptrtoaddr y)` to `icmp (x, y)`, matching the existing ptrtoint fold. Restrict both folds to only the case where the result type matches the address type. I think that all folds this can do in practice end up actually being valid for ptrtoint to a type large than the address size as well, but I don't really see a way to justify this generically without making assumptions about what kind of folding the recursive calls may do. This is based on the icmp semantics specified in https://github.com/llvm/llvm-project/pull/163936.
Author
Parents
Loading