[llvm] [EarlyCSE] Fix improper icmp simplification (PR #122043)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 8 00:14:50 PST 2025
dtcxzyw wrote:
> > > https://godbolt.org/z/1MfndEMMs
> >
> >
> > In this case, `%4` is passed into `_ZN1A5valueEv` which has `noundef` and `nonnull/dereferenceable` parameter attributes. The optimizer will assume `%4` is nonnull in the subsequent execution path.
> > Without `noundef` and `nonnull/dereferenceable`, the icmp will not be optimized out: https://godbolt.org/z/chhxE3Txr
>
> Yes, icmp is simplified with its information. Should we add the check of volatile to icmp simplify?
I mean this transformation is correct. If the loaded pointer `%4` is nonnull, it hits UB when calling `_ZN1A5valueEv`.
https://github.com/llvm/llvm-project/pull/122043
More information about the llvm-commits
mailing list