[PowerPC] Use zext instead of anyext in custom and combine (#68784)
authorNikita Popov <npopov@redhat.com>
Thu, 12 Oct 2023 07:32:17 +0000 (09:32 +0200)
committerTobias Hieta <tobias@hieta.se>
Tue, 17 Oct 2023 06:12:03 +0000 (08:12 +0200)
commit491a91e8eea27fab4d8123cbfbb01bf1cf251b9c
tree5a7e5194b6bcdf0c8cd5559355ace27f70a68a7a
parent8ce6b65c89adaabf6e1ad900c2a381241675cc0c
[PowerPC] Use zext instead of anyext in custom and combine (#68784)

This custom combine currently converts `and(anyext(x),c)` into
`anyext(and(x,c))`. This is not correct, because the original expression
guaranteed that the high bits are zero, while the new one sets them to
undef.

Emit `zext(and(x,c))` instead.

Fixes https://github.com/llvm/llvm-project/issues/68783.

(cherry picked from commit 127ed9ae266ead58aa525f74f4c86841f6674793)
llvm/lib/Target/PowerPC/PPCISelLowering.cpp
llvm/test/CodeGen/PowerPC/and-extend-combine.ll