[llvm] Zext sext undef in sdag (PR #115451)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 11 18:04:50 PST 2024
fengfeng09 wrote:
> > > This optimization is not correct for 'undef'. I think it would be correct for 'poison', but SelectionDAG doesn't have 'poison' today.
> > > See also https://blog.regehr.org/archives/1837
> >
> >
> > I see. Thanks for your explanation, so zext undef to a zero is by designed, is this right?
>
> For (zext undef), the zero extended bits of the result must be 0. The bits that started out as undef can be any value. We choose 0 for simplicity.
>
> For (sext undef), the sign extended bits must have the same value as the original sign bit. Because of undef, the original sign bit can be either 0 or 1. Folding to undef wouldn't guarantee the extended bits all match, so we fold to all 0s.
Got it, thanks.
https://github.com/llvm/llvm-project/pull/115451
More information about the llvm-commits
mailing list