[llvm] [RISCV] Generaize reduction tree matching to all integer reductions (PR #68014)
Alex Bradbury via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 4 05:31:53 PDT 2023
asb wrote:
I reverted this in 824251c9b349d859a9169196cd9533c619a715ce because I was seeing test failures due to the unguarded call to `RISCVSubtarget::getELen` in `combineBinOpOfExtractToReduceTree`, which asserts when V isn't enabled.
I've found you actually can reproduce the crash by just running the fixed-vectors-reduction-formation.ll test without `+v`. `fixed-vectors-reduction-formation.ll` doesn't crash.
Alternatively, here is a bugpoint reduced example derived from 20050604-1.c in the GCC torture suite:
```ll
%union.anon.2.3.19.20 = type { <4 x i16> }
@u = external global %union.anon.2.3.19.20, align 8
declare void @foo()
define void @main() {
entry:
%u.promoted.i = load <4 x i16>, ptr @u, align 8
%add.1.i = add <4 x i16> %u.promoted.i, <i16 24, i16 0, i16 0, i16 0>
%0 = extractelement <4 x i16> %add.1.i, i64 2
%tobool = icmp ne i16 %0, 0
%or.cond = select i1 false, i1 true, i1 %tobool
%1 = extractelement <4 x i16> %add.1.i, i64 3
%tobool5 = icmp ne i16 %1, 0
%or.cond6 = select i1 %or.cond, i1 true, i1 %tobool5
br i1 %or.cond6, label %if.then, label %if.end
if.then: ; preds = %entry
unreachable
if.end: ; preds = %entry
ret void
}
declare void @abort()
```
One obvious fix would be to return immediately from `combineBinOpOfExtractToReduceTree` if `!Subtarget.hasVInstructions()`.
https://github.com/llvm/llvm-project/pull/68014
More information about the llvm-commits
mailing list