[llvm] [RISCV][CostModel] Remove cost of icmp inst in icmp+select with SFB. (PR #91158)

Kito Cheng via llvm-commits llvm-commits at lists.llvm.org
Fri May 10 01:42:32 PDT 2024


================
@@ -0,0 +1,35 @@
+; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py
+; RUN: opt < %s -mtriple=riscv64 -mcpu=sifive-u74 -passes="print<cost-model>" -cost-kind=throughput 2>&1 -disable-output | FileCheck %s --check-prefixes=SFB64
+; RUN: opt < %s -mtriple=riscv64 -passes="print<cost-model>" -cost-kind=throughput 2>&1 -disable-output | FileCheck %s --check-prefixes=RV64
+
+define void @icmp-select() {
+; SFB64-LABEL: 'icmp-select'
+; SFB64-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: %cmp1 = icmp slt i64 0, 1
+; SFB64-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %select1 = select i1 %cmp1, i32 5, i32 4
+; SFB64-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret void
+;
+; RV64-LABEL: 'icmp-select'
+; RV64-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %cmp1 = icmp slt i64 0, 1
+; RV64-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %select1 = select i1 %cmp1, i32 5, i32 4
+; RV64-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret void
+;
+  %cmp1 = icmp slt i64 0, 1
+  %select1 = select i1 %cmp1, i32 5, i32 4
+  ret void
+}
+
+define void @fcmp-select() {
+; SFB64-LABEL: 'fcmp-select'
+; SFB64-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %fcmp1 = fcmp ogt float 0.000000e+00, 1.000000e+00
+; SFB64-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %select1 = select i1 %fcmp1, i32 5, i32 4
+; SFB64-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret void
+;
+; RV64-LABEL: 'fcmp-select'
+; RV64-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %fcmp1 = fcmp ogt float 0.000000e+00, 1.000000e+00
+; RV64-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %select1 = select i1 %fcmp1, i32 5, i32 4
+; RV64-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret void
+;
+  %fcmp1 = fcmp ogt float 0.0, 1.0
+  %select1 = select i1 %fcmp1, i32 5, i32 4
+  ret void
+}
----------------
kito-cheng wrote:

Add test case for select with vector type and floating point to make sure they didn't affected
 

https://github.com/llvm/llvm-project/pull/91158


More information about the llvm-commits mailing list