Skip to content

Commit 644fe31

Browse files
committed
Don't propagate disjoint for inreg exts, use or_is_add, match SplatPat
1 parent 6cd1750 commit 644fe31

File tree

4 files changed

+38
-6
lines changed

4 files changed

+38
-6
lines changed

llvm/include/llvm/Target/TargetSelectionDAG.td

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,10 +1113,6 @@ def not : PatFrag<(ops node:$in), (xor node:$in, -1)>;
11131113
def vnot : PatFrag<(ops node:$in), (xor node:$in, immAllOnesV)>;
11141114
def ineg : PatFrag<(ops node:$in), (sub 0, node:$in)>;
11151115

1116-
def or_disjoint : PatFrag<(ops node:$x, node:$y), (or node:$x, node:$y), [{
1117-
return N->getFlags().hasDisjoint();
1118-
}]>;
1119-
11201116
def zanyext : PatFrags<(ops node:$op),
11211117
[(zext node:$op),
11221118
(anyext node:$op)]>;

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5983,7 +5983,8 @@ SDValue DAGCombiner::hoistLogicOpWithSameOpcodeHands(SDNode *N) {
59835983
return SDValue();
59845984
// logic_op (hand_op X), (hand_op Y) --> hand_op (logic_op X, Y)
59855985
SDNodeFlags LogicFlags;
5986-
LogicFlags.setDisjoint(N->getFlags().hasDisjoint());
5986+
LogicFlags.setDisjoint(N->getFlags().hasDisjoint() &&
5987+
ISD::isExtOpcode(HandOpcode));
59875988
SDValue Logic = DAG.getNode(LogicOpcode, DL, XVT, X, Y, LogicFlags);
59885989
if (HandOpcode == ISD::SIGN_EXTEND_INREG)
59895990
return DAG.getNode(HandOpcode, DL, VT, Logic, N0.getOperand(1));

llvm/lib/Target/RISCV/RISCVInstrInfoVSDPatterns.td

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -920,10 +920,14 @@ multiclass VPatWidenOrDisjoint_VV<SDNode extop, string instruction_name> {
920920
defvar wti = vtiToWti.Wti;
921921
let Predicates = !listconcat(GetVTypePredicates<vti>.Predicates,
922922
GetVTypePredicates<wti>.Predicates) in {
923-
def : Pat<(wti.Vector (extop (vti.Vector (or_disjoint vti.RegClass:$rs2, vti.RegClass:$rs1)))),
923+
def : Pat<(wti.Vector (extop (vti.Vector (or_is_add vti.RegClass:$rs2, vti.RegClass:$rs1)))),
924924
(!cast<Instruction>(instruction_name#"_VV_"#vti.LMul.MX)
925925
(wti.Vector (IMPLICIT_DEF)), vti.RegClass:$rs2,
926926
vti.RegClass:$rs1, vti.AVL, vti.Log2SEW, TA_MA)>;
927+
def : Pat<(wti.Vector (extop (vti.Vector (or_is_add vti.RegClass:$rs2, (SplatPat (XLenVT GPR:$rs1)))))),
928+
(!cast<Instruction>(instruction_name#"_VX_"#vti.LMul.MX)
929+
(wti.Vector (IMPLICIT_DEF)), vti.RegClass:$rs2,
930+
GPR:$rs1, vti.AVL, vti.Log2SEW, TA_MA)>;
927931
}
928932
}
929933
}

llvm/test/CodeGen/RISCV/rvv/vwadd-sdnode.ll

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1443,6 +1443,37 @@ define <vscale x 2 x i32> @vwadd_vv_disjoint_or(<vscale x 2 x i16> %x.i16, <vsca
14431443
ret <vscale x 2 x i32> %or
14441444
}
14451445

1446+
define <vscale x 2 x i32> @vwaddu_vx_disjoint_or(<vscale x 2 x i16> %x.i16, i16 %y.i16) {
1447+
; CHECK-LABEL: vwaddu_vx_disjoint_or:
1448+
; CHECK: # %bb.0:
1449+
; CHECK-NEXT: vsetvli a1, zero, e16, mf2, ta, ma
1450+
; CHECK-NEXT: vwaddu.vx v9, v8, a0
1451+
; CHECK-NEXT: vmv1r.v v8, v9
1452+
; CHECK-NEXT: ret
1453+
%x.i32 = zext <vscale x 2 x i16> %x.i16 to <vscale x 2 x i32>
1454+
%y.head = insertelement <vscale x 2 x i16> poison, i16 %y.i16, i32 0
1455+
%y.splat = shufflevector <vscale x 2 x i16> %y.head, <vscale x 2 x i16> poison, <vscale x 2 x i32> zeroinitializer
1456+
%y.i32 = zext <vscale x 2 x i16> %y.splat to <vscale x 2 x i32>
1457+
%or = or disjoint <vscale x 2 x i32> %x.i32, %y.i32
1458+
ret <vscale x 2 x i32> %or
1459+
}
1460+
1461+
1462+
define <vscale x 2 x i32> @vwadd_vx_disjoint_or(<vscale x 2 x i16> %x.i16, i16 %y.i16) {
1463+
; CHECK-LABEL: vwadd_vx_disjoint_or:
1464+
; CHECK: # %bb.0:
1465+
; CHECK-NEXT: vsetvli a1, zero, e16, mf2, ta, ma
1466+
; CHECK-NEXT: vwadd.vx v9, v8, a0
1467+
; CHECK-NEXT: vmv1r.v v8, v9
1468+
; CHECK-NEXT: ret
1469+
%x.i32 = sext <vscale x 2 x i16> %x.i16 to <vscale x 2 x i32>
1470+
%y.head = insertelement <vscale x 2 x i16> poison, i16 %y.i16, i32 0
1471+
%y.splat = shufflevector <vscale x 2 x i16> %y.head, <vscale x 2 x i16> poison, <vscale x 2 x i32> zeroinitializer
1472+
%y.i32 = sext <vscale x 2 x i16> %y.splat to <vscale x 2 x i32>
1473+
%or = or disjoint <vscale x 2 x i32> %x.i32, %y.i32
1474+
ret <vscale x 2 x i32> %or
1475+
}
1476+
14461477
define <vscale x 2 x i32> @vwaddu_wv_disjoint_or(<vscale x 2 x i32> %x.i32, <vscale x 2 x i16> %y.i16) {
14471478
; CHECK-LABEL: vwaddu_wv_disjoint_or:
14481479
; CHECK: # %bb.0:

0 commit comments

Comments
 (0)