Skip to content

Commit 885b8d9

Browse files
committed
[RISCV] Enable mul strength reduction for XTheadBa
This vendor extension has the same shift_add as zba, and most of the same patterns are duplicated. Enable it here too so the configurations don't diverge.
1 parent b6bd41d commit 885b8d9

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13408,7 +13408,7 @@ static SDValue expandMul(SDNode *N, SelectionDAG &DAG,
1340813408
if (VT != Subtarget.getXLenVT())
1340913409
return SDValue();
1341013410

13411-
if (!Subtarget.hasStdExtZba())
13411+
if (!Subtarget.hasStdExtZba() && !Subtarget.hasVendorXTHeadBa())
1341213412
return SDValue();
1341313413

1341413414
ConstantSDNode *CNode = dyn_cast<ConstantSDNode>(N->getOperand(1));

llvm/test/CodeGen/RISCV/rv64xtheadba.ll

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,23 @@ define i64 @mul96(i64 %a) {
268268
ret i64 %c
269269
}
270270

271+
define i64 @mul137(i64 %a) {
272+
; RV64I-LABEL: mul137:
273+
; RV64I: # %bb.0:
274+
; RV64I-NEXT: li a1, 137
275+
; RV64I-NEXT: mul a0, a0, a1
276+
; RV64I-NEXT: ret
277+
;
278+
; RV64XTHEADBA-LABEL: mul137:
279+
; RV64XTHEADBA: # %bb.0:
280+
; RV64XTHEADBA-NEXT: th.addsl a1, a0, a0, 3
281+
; RV64XTHEADBA-NEXT: slli a0, a0, 7
282+
; RV64XTHEADBA-NEXT: add a0, a0, a1
283+
; RV64XTHEADBA-NEXT: ret
284+
%c = mul i64 %a, 137
285+
ret i64 %c
286+
}
287+
271288
define i64 @mul160(i64 %a) {
272289
; RV64I-LABEL: mul160:
273290
; RV64I: # %bb.0:

0 commit comments

Comments
 (0)