diff options
| author | Craig Topper <craig.topper@sifive.com> | 2023-06-26 11:55:56 -0700 |
|---|---|---|
| committer | Craig Topper <craig.topper@sifive.com> | 2023-06-26 11:56:17 -0700 |
| commit | 4afa2ab7a56522f9879f99c7a0331d65e81bbca9 (patch) | |
| tree | 9f8746d7f2521ab7172a32e642e051f68b670696 | |
| parent | cb26c1c745e899c839cb05eacad03efa55c69996 (diff) | |
| download | llvm-4afa2ab7a56522f9879f99c7a0331d65e81bbca9.zip llvm-4afa2ab7a56522f9879f99c7a0331d65e81bbca9.tar.gz llvm-4afa2ab7a56522f9879f99c7a0331d65e81bbca9.tar.bz2 | |
[RISCV][SelectionDAGBuilder] Fix an implicit scalable TypeSize to fixed size conversion in getUniformBase.
If the index needs to be scaled by a scalable size, just give up.
Fixes #63459
Reviewed By: frasercrmck, RKSimon
Differential Revision: https://reviews.llvm.org/D153601
| -rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | 6 | ||||
| -rw-r--r-- | llvm/test/CodeGen/RISCV/rvv/pr63459.ll | 21 |
2 files changed, 25 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp index 0e4f1bc..fccc2b1 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -4503,11 +4503,13 @@ static bool getUniformBase(const Value *Ptr, SDValue &Base, SDValue &Index, if (BasePtr->getType()->isVectorTy() || !IndexVal->getType()->isVectorTy()) return false; - uint64_t ScaleVal = DL.getTypeAllocSize(GEP->getResultElementType()); + TypeSize ScaleVal = DL.getTypeAllocSize(GEP->getResultElementType()); + if (ScaleVal.isScalable()) + return false; // Target may not support the required addressing mode. if (ScaleVal != 1 && - !TLI.isLegalScaleForGatherScatter(ScaleVal, ElemSize)) + !TLI.isLegalScaleForGatherScatter(ScaleVal.getFixedValue(), ElemSize)) return false; Base = SDB->getValue(BasePtr); diff --git a/llvm/test/CodeGen/RISCV/rvv/pr63459.ll b/llvm/test/CodeGen/RISCV/rvv/pr63459.ll new file mode 100644 index 0000000..c871e29 --- /dev/null +++ b/llvm/test/CodeGen/RISCV/rvv/pr63459.ll @@ -0,0 +1,21 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2 +; RUN: llc < %s -mtriple=riscv64 -mattr=+v | FileCheck %s + +define void @snork(ptr %arg, <vscale x 2 x i64> %arg1) { +; CHECK-LABEL: snork: +; CHECK: # %bb.0: # %bb +; CHECK-NEXT: csrr a1, vlenb +; CHECK-NEXT: vsetvli a2, zero, e64, m2, ta, ma +; CHECK-NEXT: vmul.vx v8, v8, a1 +; CHECK-NEXT: vsetvli zero, zero, e32, m1, ta, ma +; CHECK-NEXT: vmv.v.i v10, 1 +; CHECK-NEXT: vsetivli zero, 4, e32, m1, ta, ma +; CHECK-NEXT: vsoxei64.v v10, (a0), v8 +; CHECK-NEXT: ret +bb: + %getelementptr = getelementptr inbounds <vscale x 2 x i32>, ptr %arg, <vscale x 2 x i64> %arg1 + tail call void @llvm.vp.scatter.nxv2i32.nxv2p0(<vscale x 2 x i32> shufflevector (<vscale x 2 x i32> insertelement (<vscale x 2 x i32> poison, i32 1, i32 0), <vscale x 2 x i32> poison, <vscale x 2 x i32> zeroinitializer), <vscale x 2 x ptr> align 4 %getelementptr, <vscale x 2 x i1> shufflevector (<vscale x 2 x i1> insertelement (<vscale x 2 x i1> poison, i1 true, i64 0), <vscale x 2 x i1> poison, <vscale x 2 x i32> zeroinitializer), i32 4) + ret void +} + +declare void @llvm.vp.scatter.nxv2i32.nxv2p0(<vscale x 2 x i32>, <vscale x 2 x ptr>, <vscale x 2 x i1>, i32) |
