Skip to content

Commit 54ae24e

Browse files
committed
[RISCV][VLOPT] skip EMUL is unknown before enter EMULAndEEWAreEqual
Fix #139288
1 parent 49ab1d7 commit 54ae24e

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

llvm/lib/Target/RISCV/RISCVVLOptimizer.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1383,6 +1383,11 @@ RISCVVLOptimizer::checkUsers(const MachineInstr &MI) const {
13831383
// If the operand is used as a scalar operand, then the EEW must be
13841384
// compatible. Otherwise, the EMUL *and* EEW must be compatible.
13851385
bool IsVectorOpUsedAsScalarOp = isVectorOpUsedAsScalarOp(UserOp);
1386+
1387+
if (!IsVectorOpUsedAsScalarOp &&
1388+
(!ConsumerInfo->EMUL || !ProducerInfo->EMUL))
1389+
return std::nullopt;
1390+
13861391
if ((IsVectorOpUsedAsScalarOp &&
13871392
!OperandInfo::EEWAreEqual(*ConsumerInfo, *ProducerInfo)) ||
13881393
(!IsVectorOpUsedAsScalarOp &&
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 3
2+
; RUN: llc -mtriple=riscv64 -mattr=+v < %s | FileCheck %s
3+
4+
define i32 @pps_is_equal(<vscale x 16 x i1> %0, <vscale x 16 x i1> %1) #0 {
5+
; CHECK-LABEL: pps_is_equal:
6+
; CHECK: # %bb.0: # %entry
7+
; CHECK-NEXT: vsetivli zero, 1, e32, m8, ta, ma
8+
; CHECK-NEXT: vmclr.m v8
9+
; CHECK-NEXT: vmv.s.x v16, zero
10+
; CHECK-NEXT: vmor.mm v0, v8, v8
11+
; CHECK-NEXT: vmv.v.i v8, 0
12+
; CHECK-NEXT: vredmax.vs v8, v8, v16, v0.t
13+
; CHECK-NEXT: vmv.x.s a0, v8
14+
; CHECK-NEXT: ret
15+
entry:
16+
%2 = tail call <vscale x 16 x i1> @llvm.vp.or.nxv16i1(<vscale x 16 x i1> zeroinitializer, <vscale x 16 x i1> zeroinitializer, <vscale x 16 x i1> %0, i32 1)
17+
%3 = tail call i32 @llvm.vp.reduce.smax.nxv16i32(i32 0, <vscale x 16 x i32> zeroinitializer, <vscale x 16 x i1> %2, i32 1)
18+
ret i32 %3
19+
}
20+
21+
declare <vscale x 16 x i1> @llvm.vp.or.nxv16i1(<vscale x 16 x i1>, <vscale x 16 x i1>, <vscale x 16 x i1>, i32) #1
22+
declare i32 @llvm.vp.reduce.smax.nxv16i32(i32, <vscale x 16 x i32>, <vscale x 16 x i1>, i32) #1

0 commit comments

Comments
 (0)