Fix i1 vector reduction miscompilation
authorSp00ph <markuseverling@gmail.com>
Thu, 20 Apr 2023 22:26:49 +0000 (15:26 -0700)
committerCraig Topper <craig.topper@sifive.com>
Thu, 20 Apr 2023 22:26:49 +0000 (15:26 -0700)
commit3c9083f6757cbaf6f8d6c601586d99a11faf642e
tree01f78651eaf6fe5245448c7c958c22bf4cdb25c9
parented35b584daeda352d4ad109edc3bc04de798a1ac
Fix i1 vector reduction miscompilation

Previously, `vecreduce_{and,or} vNi1` could lead to miscompilations because the legalizer first decides to `any_ext` the operand (which is correct for `vecreduce_{and,or}`) and then decides to use `vecreduce_u{min,max}` instead (for which `any_ext` is incorrect). This patch changes it so the `vecreduce_u{min,max}` operations use `sign_ext` instead of `any_ext`.

Issue: https://github.com/llvm/llvm-project/issues/62211

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D148672
llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
llvm/test/CodeGen/AArch64/illegal-floating-point-vector-compares.ll
llvm/test/CodeGen/AArch64/reduce-and.ll
llvm/test/CodeGen/AArch64/reduce-or.ll
llvm/test/CodeGen/AArch64/sve-fixed-length-ptest.ll
llvm/test/CodeGen/AArch64/vecreduce-and-legalization.ll
llvm/test/CodeGen/AArch64/vecreduce-umax-legalization.ll