[llvm] [RISCV][TTI] Add llvm.vp.select into canSplatOperand. (PR #117982)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 28 01:48:55 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-risc-v
Author: LiqinWeng (LiqinWeng)
<details>
<summary>Changes</summary>
---
Patch is 134.56 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/117982.diff
2 Files Affected:
- (modified) llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp (+1)
- (modified) llvm/test/CodeGen/RISCV/rvv/sink-splat-operands.ll (+566-411)
``````````diff
diff --git a/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp b/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
index 8f0ef69258b165..6af6e8b84bef38 100644
--- a/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
+++ b/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
@@ -2404,6 +2404,7 @@ bool RISCVTTIImpl::canSplatOperand(Instruction *I, int Operand) const {
case Intrinsic::vp_ssub_sat:
case Intrinsic::usub_sat:
case Intrinsic::vp_usub_sat:
+ case Intrinsic::vp_select:
return Operand == 1;
// These intrinsics are commutative.
case Intrinsic::vp_add:
diff --git a/llvm/test/CodeGen/RISCV/rvv/sink-splat-operands.ll b/llvm/test/CodeGen/RISCV/rvv/sink-splat-operands.ll
index c91b02e8f15e47..e42ad7719707fb 100644
--- a/llvm/test/CodeGen/RISCV/rvv/sink-splat-operands.ll
+++ b/llvm/test/CodeGen/RISCV/rvv/sink-splat-operands.ll
@@ -2,7 +2,7 @@
; RUN: llc < %s -mtriple=riscv64 -mattr=+m,+v,+f -target-abi=lp64f \
; RUN: | FileCheck %s
-define void @sink_splat_mul(ptr nocapture %a, i32 signext %x) {
+define void @sink_splat_mul(ptr %a, i32 %x) {
; CHECK-LABEL: sink_splat_mul:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: lui a2, 1
@@ -22,7 +22,7 @@ entry:
%broadcast.splat = shufflevector <4 x i32> %broadcast.splatinsert, <4 x i32> poison, <4 x i32> zeroinitializer
br label %vector.body
-vector.body: ; preds = %vector.body, %entry
+vector.body:
%index = phi i64 [ 0, %entry ], [ %index.next, %vector.body ]
%0 = getelementptr inbounds i32, ptr %a, i64 %index
%wide.load = load <4 x i32>, ptr %0, align 4
@@ -32,11 +32,11 @@ vector.body: ; preds = %vector.body, %entry
%2 = icmp eq i64 %index.next, 1024
br i1 %2, label %for.cond.cleanup, label %vector.body
-for.cond.cleanup: ; preds = %vector.body
+for.cond.cleanup:
ret void
}
-define void @sink_splat_add(ptr nocapture %a, i32 signext %x) {
+define void @sink_splat_add(ptr %a, i32 %x) {
; CHECK-LABEL: sink_splat_add:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: lui a2, 1
@@ -56,7 +56,7 @@ entry:
%broadcast.splat = shufflevector <4 x i32> %broadcast.splatinsert, <4 x i32> poison, <4 x i32> zeroinitializer
br label %vector.body
-vector.body: ; preds = %vector.body, %entry
+vector.body:
%index = phi i64 [ 0, %entry ], [ %index.next, %vector.body ]
%0 = getelementptr inbounds i32, ptr %a, i64 %index
%wide.load = load <4 x i32>, ptr %0, align 4
@@ -66,11 +66,11 @@ vector.body: ; preds = %vector.body, %entry
%2 = icmp eq i64 %index.next, 1024
br i1 %2, label %for.cond.cleanup, label %vector.body
-for.cond.cleanup: ; preds = %vector.body
+for.cond.cleanup:
ret void
}
-define void @sink_splat_sub(ptr nocapture %a, i32 signext %x) {
+define void @sink_splat_sub(ptr %a, i32 %x) {
; CHECK-LABEL: sink_splat_sub:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: lui a2, 1
@@ -90,7 +90,7 @@ entry:
%broadcast.splat = shufflevector <4 x i32> %broadcast.splatinsert, <4 x i32> poison, <4 x i32> zeroinitializer
br label %vector.body
-vector.body: ; preds = %vector.body, %entry
+vector.body:
%index = phi i64 [ 0, %entry ], [ %index.next, %vector.body ]
%0 = getelementptr inbounds i32, ptr %a, i64 %index
%wide.load = load <4 x i32>, ptr %0, align 4
@@ -100,11 +100,11 @@ vector.body: ; preds = %vector.body, %entry
%2 = icmp eq i64 %index.next, 1024
br i1 %2, label %for.cond.cleanup, label %vector.body
-for.cond.cleanup: ; preds = %vector.body
+for.cond.cleanup:
ret void
}
-define void @sink_splat_rsub(ptr nocapture %a, i32 signext %x) {
+define void @sink_splat_rsub(ptr %a, i32 %x) {
; CHECK-LABEL: sink_splat_rsub:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: lui a2, 1
@@ -124,7 +124,7 @@ entry:
%broadcast.splat = shufflevector <4 x i32> %broadcast.splatinsert, <4 x i32> poison, <4 x i32> zeroinitializer
br label %vector.body
-vector.body: ; preds = %vector.body, %entry
+vector.body:
%index = phi i64 [ 0, %entry ], [ %index.next, %vector.body ]
%0 = getelementptr inbounds i32, ptr %a, i64 %index
%wide.load = load <4 x i32>, ptr %0, align 4
@@ -134,11 +134,11 @@ vector.body: ; preds = %vector.body, %entry
%2 = icmp eq i64 %index.next, 1024
br i1 %2, label %for.cond.cleanup, label %vector.body
-for.cond.cleanup: ; preds = %vector.body
+for.cond.cleanup:
ret void
}
-define void @sink_splat_and(ptr nocapture %a, i32 signext %x) {
+define void @sink_splat_and(ptr %a, i32 %x) {
; CHECK-LABEL: sink_splat_and:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: lui a2, 1
@@ -158,7 +158,7 @@ entry:
%broadcast.splat = shufflevector <4 x i32> %broadcast.splatinsert, <4 x i32> poison, <4 x i32> zeroinitializer
br label %vector.body
-vector.body: ; preds = %vector.body, %entry
+vector.body:
%index = phi i64 [ 0, %entry ], [ %index.next, %vector.body ]
%0 = getelementptr inbounds i32, ptr %a, i64 %index
%wide.load = load <4 x i32>, ptr %0, align 4
@@ -168,11 +168,11 @@ vector.body: ; preds = %vector.body, %entry
%2 = icmp eq i64 %index.next, 1024
br i1 %2, label %for.cond.cleanup, label %vector.body
-for.cond.cleanup: ; preds = %vector.body
+for.cond.cleanup:
ret void
}
-define void @sink_splat_or(ptr nocapture %a, i32 signext %x) {
+define void @sink_splat_or(ptr %a, i32 %x) {
; CHECK-LABEL: sink_splat_or:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: lui a2, 1
@@ -192,7 +192,7 @@ entry:
%broadcast.splat = shufflevector <4 x i32> %broadcast.splatinsert, <4 x i32> poison, <4 x i32> zeroinitializer
br label %vector.body
-vector.body: ; preds = %vector.body, %entry
+vector.body:
%index = phi i64 [ 0, %entry ], [ %index.next, %vector.body ]
%0 = getelementptr inbounds i32, ptr %a, i64 %index
%wide.load = load <4 x i32>, ptr %0, align 4
@@ -202,11 +202,11 @@ vector.body: ; preds = %vector.body, %entry
%2 = icmp eq i64 %index.next, 1024
br i1 %2, label %for.cond.cleanup, label %vector.body
-for.cond.cleanup: ; preds = %vector.body
+for.cond.cleanup:
ret void
}
-define void @sink_splat_xor(ptr nocapture %a, i32 signext %x) {
+define void @sink_splat_xor(ptr %a, i32 %x) {
; CHECK-LABEL: sink_splat_xor:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: lui a2, 1
@@ -226,7 +226,7 @@ entry:
%broadcast.splat = shufflevector <4 x i32> %broadcast.splatinsert, <4 x i32> poison, <4 x i32> zeroinitializer
br label %vector.body
-vector.body: ; preds = %vector.body, %entry
+vector.body:
%index = phi i64 [ 0, %entry ], [ %index.next, %vector.body ]
%0 = getelementptr inbounds i32, ptr %a, i64 %index
%wide.load = load <4 x i32>, ptr %0, align 4
@@ -236,11 +236,11 @@ vector.body: ; preds = %vector.body, %entry
%2 = icmp eq i64 %index.next, 1024
br i1 %2, label %for.cond.cleanup, label %vector.body
-for.cond.cleanup: ; preds = %vector.body
+for.cond.cleanup:
ret void
}
-define void @sink_splat_mul_scalable(ptr nocapture %a, i32 signext %x) {
+define void @sink_splat_mul_scalable(ptr %a, i32 %x) {
; CHECK-LABEL: sink_splat_mul_scalable:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: csrr a5, vlenb
@@ -331,7 +331,7 @@ for.body: ; preds = %for.body.preheader,
br i1 %cmp.not, label %for.cond.cleanup, label %for.body
}
-define void @sink_splat_add_scalable(ptr nocapture %a, i32 signext %x) {
+define void @sink_splat_add_scalable(ptr %a, i32 %x) {
; CHECK-LABEL: sink_splat_add_scalable:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: csrr a5, vlenb
@@ -422,7 +422,7 @@ for.body: ; preds = %for.body.preheader,
br i1 %cmp.not, label %for.cond.cleanup, label %for.body
}
-define void @sink_splat_sub_scalable(ptr nocapture %a, i32 signext %x) {
+define void @sink_splat_sub_scalable(ptr %a, i32 %x) {
; CHECK-LABEL: sink_splat_sub_scalable:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: csrr a5, vlenb
@@ -513,7 +513,7 @@ for.body: ; preds = %for.body.preheader,
br i1 %cmp.not, label %for.cond.cleanup, label %for.body
}
-define void @sink_splat_rsub_scalable(ptr nocapture %a, i32 signext %x) {
+define void @sink_splat_rsub_scalable(ptr %a, i32 %x) {
; CHECK-LABEL: sink_splat_rsub_scalable:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: csrr a5, vlenb
@@ -604,7 +604,7 @@ for.body: ; preds = %for.body.preheader,
br i1 %cmp.not, label %for.cond.cleanup, label %for.body
}
-define void @sink_splat_and_scalable(ptr nocapture %a, i32 signext %x) {
+define void @sink_splat_and_scalable(ptr %a, i32 %x) {
; CHECK-LABEL: sink_splat_and_scalable:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: csrr a5, vlenb
@@ -695,7 +695,7 @@ for.body: ; preds = %for.body.preheader,
br i1 %cmp.not, label %for.cond.cleanup, label %for.body
}
-define void @sink_splat_or_scalable(ptr nocapture %a, i32 signext %x) {
+define void @sink_splat_or_scalable(ptr %a, i32 %x) {
; CHECK-LABEL: sink_splat_or_scalable:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: csrr a5, vlenb
@@ -786,7 +786,7 @@ for.body: ; preds = %for.body.preheader,
br i1 %cmp.not, label %for.cond.cleanup, label %for.body
}
-define void @sink_splat_xor_scalable(ptr nocapture %a, i32 signext %x) {
+define void @sink_splat_xor_scalable(ptr %a, i32 %x) {
; CHECK-LABEL: sink_splat_xor_scalable:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: csrr a5, vlenb
@@ -877,7 +877,7 @@ for.body: ; preds = %for.body.preheader,
br i1 %cmp.not, label %for.cond.cleanup, label %for.body
}
-define void @sink_splat_shl(ptr nocapture %a, i32 signext %x) {
+define void @sink_splat_shl(ptr %a, i32 %x) {
; CHECK-LABEL: sink_splat_shl:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: lui a2, 1
@@ -897,7 +897,7 @@ entry:
%broadcast.splat = shufflevector <4 x i32> %broadcast.splatinsert, <4 x i32> poison, <4 x i32> zeroinitializer
br label %vector.body
-vector.body: ; preds = %vector.body, %entry
+vector.body:
%index = phi i64 [ 0, %entry ], [ %index.next, %vector.body ]
%0 = getelementptr inbounds i32, ptr %a, i64 %index
%wide.load = load <4 x i32>, ptr %0, align 4
@@ -907,11 +907,11 @@ vector.body: ; preds = %vector.body, %entry
%2 = icmp eq i64 %index.next, 1024
br i1 %2, label %for.cond.cleanup, label %vector.body
-for.cond.cleanup: ; preds = %vector.body
+for.cond.cleanup:
ret void
}
-define void @sink_splat_lshr(ptr nocapture %a, i32 signext %x) {
+define void @sink_splat_lshr(ptr %a, i32 %x) {
; CHECK-LABEL: sink_splat_lshr:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: lui a2, 1
@@ -931,7 +931,7 @@ entry:
%broadcast.splat = shufflevector <4 x i32> %broadcast.splatinsert, <4 x i32> poison, <4 x i32> zeroinitializer
br label %vector.body
-vector.body: ; preds = %vector.body, %entry
+vector.body:
%index = phi i64 [ 0, %entry ], [ %index.next, %vector.body ]
%0 = getelementptr inbounds i32, ptr %a, i64 %index
%wide.load = load <4 x i32>, ptr %0, align 4
@@ -941,11 +941,11 @@ vector.body: ; preds = %vector.body, %entry
%2 = icmp eq i64 %index.next, 1024
br i1 %2, label %for.cond.cleanup, label %vector.body
-for.cond.cleanup: ; preds = %vector.body
+for.cond.cleanup:
ret void
}
-define void @sink_splat_ashr(ptr nocapture %a, i32 signext %x) {
+define void @sink_splat_ashr(ptr %a, i32 %x) {
; CHECK-LABEL: sink_splat_ashr:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: lui a2, 1
@@ -965,7 +965,7 @@ entry:
%broadcast.splat = shufflevector <4 x i32> %broadcast.splatinsert, <4 x i32> poison, <4 x i32> zeroinitializer
br label %vector.body
-vector.body: ; preds = %vector.body, %entry
+vector.body:
%index = phi i64 [ 0, %entry ], [ %index.next, %vector.body ]
%0 = getelementptr inbounds i32, ptr %a, i64 %index
%wide.load = load <4 x i32>, ptr %0, align 4
@@ -975,11 +975,11 @@ vector.body: ; preds = %vector.body, %entry
%2 = icmp eq i64 %index.next, 1024
br i1 %2, label %for.cond.cleanup, label %vector.body
-for.cond.cleanup: ; preds = %vector.body
+for.cond.cleanup:
ret void
}
-define void @sink_splat_shl_scalable(ptr nocapture %a, i32 signext %x) {
+define void @sink_splat_shl_scalable(ptr %a, i32 %x) {
; CHECK-LABEL: sink_splat_shl_scalable:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: csrr a5, vlenb
@@ -1070,7 +1070,7 @@ for.body: ; preds = %for.body.preheader,
br i1 %cmp.not, label %for.cond.cleanup, label %for.body
}
-define void @sink_splat_lshr_scalable(ptr nocapture %a, i32 signext %x) {
+define void @sink_splat_lshr_scalable(ptr %a, i32 %x) {
; CHECK-LABEL: sink_splat_lshr_scalable:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: csrr a5, vlenb
@@ -1161,7 +1161,7 @@ for.body: ; preds = %for.body.preheader,
br i1 %cmp.not, label %for.cond.cleanup, label %for.body
}
-define void @sink_splat_ashr_scalable(ptr nocapture %a) {
+define void @sink_splat_ashr_scalable(ptr %a) {
; CHECK-LABEL: sink_splat_ashr_scalable:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: csrr a4, vlenb
@@ -1250,7 +1250,7 @@ for.body: ; preds = %for.body.preheader,
br i1 %cmp.not, label %for.cond.cleanup, label %for.body
}
-define void @sink_splat_fmul(ptr nocapture %a, float %x) {
+define void @sink_splat_fmul(ptr %a, float %x) {
; CHECK-LABEL: sink_splat_fmul:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: lui a1, 1
@@ -1270,7 +1270,7 @@ entry:
%broadcast.splat = shufflevector <4 x float> %broadcast.splatinsert, <4 x float> poison, <4 x i32> zeroinitializer
br label %vector.body
-vector.body: ; preds = %vector.body, %entry
+vector.body:
%index = phi i64 [ 0, %entry ], [ %index.next, %vector.body ]
%0 = getelementptr inbounds float, ptr %a, i64 %index
%wide.load = load <4 x float>, ptr %0, align 4
@@ -1280,11 +1280,11 @@ vector.body: ; preds = %vector.body, %entry
%2 = icmp eq i64 %index.next, 1024
br i1 %2, label %for.cond.cleanup, label %vector.body
-for.cond.cleanup: ; preds = %vector.body
+for.cond.cleanup:
ret void
}
-define void @sink_splat_fdiv(ptr nocapture %a, float %x) {
+define void @sink_splat_fdiv(ptr %a, float %x) {
; CHECK-LABEL: sink_splat_fdiv:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: lui a1, 1
@@ -1304,7 +1304,7 @@ entry:
%broadcast.splat = shufflevector <4 x float> %broadcast.splatinsert, <4 x float> poison, <4 x i32> zeroinitializer
br label %vector.body
-vector.body: ; preds = %vector.body, %entry
+vector.body:
%index = phi i64 [ 0, %entry ], [ %index.next, %vector.body ]
%0 = getelementptr inbounds float, ptr %a, i64 %index
%wide.load = load <4 x float>, ptr %0, align 4
@@ -1314,11 +1314,11 @@ vector.body: ; preds = %vector.body, %entry
%2 = icmp eq i64 %index.next, 1024
br i1 %2, label %for.cond.cleanup, label %vector.body
-for.cond.cleanup: ; preds = %vector.body
+for.cond.cleanup:
ret void
}
-define void @sink_splat_frdiv(ptr nocapture %a, float %x) {
+define void @sink_splat_frdiv(ptr %a, float %x) {
; CHECK-LABEL: sink_splat_frdiv:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: lui a1, 1
@@ -1338,7 +1338,7 @@ entry:
%broadcast.splat = shufflevector <4 x float> %broadcast.splatinsert, <4 x float> poison, <4 x i32> zeroinitializer
br label %vector.body
-vector.body: ; preds = %vector.body, %entry
+vector.body:
%index = phi i64 [ 0, %entry ], [ %index.next, %vector.body ]
%0 = getelementptr inbounds float, ptr %a, i64 %index
%wide.load = load <4 x float>, ptr %0, align 4
@@ -1348,11 +1348,11 @@ vector.body: ; preds = %vector.body, %entry
%2 = icmp eq i64 %index.next, 1024
br i1 %2, label %for.cond.cleanup, label %vector.body
-for.cond.cleanup: ; preds = %vector.body
+for.cond.cleanup:
ret void
}
-define void @sink_splat_fadd(ptr nocapture %a, float %x) {
+define void @sink_splat_fadd(ptr %a, float %x) {
; CHECK-LABEL: sink_splat_fadd:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: lui a1, 1
@@ -1372,7 +1372,7 @@ entry:
%broadcast.splat = shufflevector <4 x float> %broadcast.splatinsert, <4 x float> poison, <4 x i32> zeroinitializer
br label %vector.body
-vector.body: ; preds = %vector.body, %entry
+vector.body:
%index = phi i64 [ 0, %entry ], [ %index.next, %vector.body ]
%0 = getelementptr inbounds float, ptr %a, i64 %index
%wide.load = load <4 x float>, ptr %0, align 4
@@ -1382,11 +1382,11 @@ vector.body: ; preds = %vector.body, %entry
%2 = icmp eq i64 %index.next, 1024
br i1 %2, label %for.cond.cleanup, label %vector.body
-for.cond.cleanup: ; preds = %vector.body
+for.cond.cleanup:
ret void
}
-define void @sink_splat_fsub(ptr nocapture %a, float %x) {
+define void @sink_splat_fsub(ptr %a, float %x) {
; CHECK-LABEL: sink_splat_fsub:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: lui a1, 1
@@ -1406,7 +1406,7 @@ entry:
%broadcast.splat = shufflevector <4 x float> %broadcast.splatinsert, <4 x float> poison, <4 x i32> zeroinitializer
br label %vector.body
-vector.body: ; preds = %vector.body, %entry
+vector.body:
%index = phi i64 [ 0, %entry ], [ %index.next, %vector.body ]
%0 = getelementptr inbounds float, ptr %a, i64 %index
%wide.load = load <4 x float>, ptr %0, align 4
@@ -1416,11 +1416,11 @@ vector.body: ; preds = %vector.body, %entry
%2 = icmp eq i64 %index.next, 1024
br i1 %2, label %for.cond.cleanup, label %vector.body
-for.cond.cleanup: ; preds = %vector.body
+for.cond.cleanup:
ret void
}
-define void @sink_splat_frsub(ptr nocapture %a, float %x) {
+define void @sink_splat_frsub(ptr %a, float %x) {
; CHECK-LABEL: sink_splat_frsub:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: lui a1, 1
@@ -1440,7 +1440,7 @@ entry:
%broadcast.splat = shufflevector <4 x float> %broadcast.splatinsert, <4 x float> poison, <4 x i32> zeroinitializer
br label %vector.body
-vector.body: ; preds = %vector.body, %entry
+vector.body:
%index = phi i64 [ 0, %entry ], [ %index.next, %vector.body ]
%0 = getelementptr inbounds float, ptr %a, i64 %index
%wide.load = load <4 x float>, ptr %0, align 4
@@ -1450,11 +1450,11 @@ vector.body: ; preds = %vector.body, %entry
%2 = icmp eq i64 %index.next, 1024
br i1 %2, label %for.cond.cleanup, label %vector.body
-for.cond.cleanup: ; preds = %vector.body
+for.cond.cleanup:
ret void
}
-define void @sink_splat_fmul_scalable(ptr nocapture %a, float %x) {
+define void @sink_splat_fmul_scalable(ptr %a, float %x) {
; CHECK-LABEL: sink_splat_fmul_scalable:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: csrr a1, vlenb
@@...
[truncated]
``````````
</details>
https://github.com/llvm/llvm-project/pull/117982
More information about the llvm-commits
mailing list