[PATCH] D123796: [RISCV] Don't emit fractional VIDs with negative steps
Fraser Cormack via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 20 23:12:39 PDT 2022
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3e678cb77264: [RISCV] Don't emit fractional VIDs with negative steps (authored by frasercrmck).
Changed prior to commit:
https://reviews.llvm.org/D123796?vs=423559&id=424098#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D123796/new/
https://reviews.llvm.org/D123796
Files:
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
llvm/test/CodeGen/RISCV/rvv/fixed-vectors-int-buildvec.ll
Index: llvm/test/CodeGen/RISCV/rvv/fixed-vectors-int-buildvec.ll
===================================================================
--- llvm/test/CodeGen/RISCV/rvv/fixed-vectors-int-buildvec.ll
+++ llvm/test/CodeGen/RISCV/rvv/fixed-vectors-int-buildvec.ll
@@ -746,17 +746,17 @@
ret <4 x i8> <i8 3, i8 3, i8 1, i8 0>
}
-; FIXME: This is not a valid way to emit this vid sequence: shift-right for
-; division only works for non-negative numbers!
+; We match this as a VID sequence (-3 / 8) + 5 but choose not to introduce
+; division to compute it.
define <16 x i8> @buildvec_not_vid_v16i8() {
; CHECK-LABEL: buildvec_not_vid_v16i8:
; CHECK: # %bb.0:
+; CHECK-NEXT: li a0, 3
; CHECK-NEXT: vsetivli zero, 16, e8, m1, ta, mu
-; CHECK-NEXT: vid.v v8
-; CHECK-NEXT: li a0, -3
-; CHECK-NEXT: vmul.vx v8, v8, a0
-; CHECK-NEXT: vsrl.vi v8, v8, 3
-; CHECK-NEXT: vadd.vi v8, v8, 5
+; CHECK-NEXT: vmv.s.x v9, a0
+; CHECK-NEXT: vmv.v.i v8, 0
+; CHECK-NEXT: vsetivli zero, 7, e8, m1, tu, mu
+; CHECK-NEXT: vslideup.vi v8, v9, 6
; CHECK-NEXT: ret
ret <16 x i8> <i8 undef, i8 undef, i8 undef, i8 undef, i8 undef, i8 undef, i8 3, i8 undef, i8 undef, i8 undef, i8 undef, i8 undef, i8 undef, i8 undef, i8 0, i8 0>
}
Index: llvm/lib/Target/RISCV/RISCVISelLowering.cpp
===================================================================
--- llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -2186,7 +2186,8 @@
// a single addi instruction.
if (((StepOpcode == ISD::MUL && isInt<12>(SplatStepVal)) ||
(StepOpcode == ISD::SHL && isUInt<5>(SplatStepVal))) &&
- isPowerOf2_32(StepDenominator) && isInt<5>(Addend)) {
+ isPowerOf2_32(StepDenominator) &&
+ (SplatStepVal >= 0 || StepDenominator == 1) && isInt<5>(Addend)) {
SDValue VID = DAG.getNode(RISCVISD::VID_VL, DL, ContainerVT, Mask, VL);
// Convert right out of the scalable type so we can use standard ISD
// nodes for the rest of the computation. If we used scalable types with
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D123796.424098.patch
Type: text/x-patch
Size: 2075 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220421/dcda1296/attachment.bin>
More information about the llvm-commits
mailing list