[PATCH] D149169: [RISCV] Cost constant materialization of vectors in phis

Alexey Bataev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 26 09:24:14 PDT 2023


ABataev added inline comments.


================
Comment at: llvm/test/Analysis/CostModel/RISCV/rvv-phi-const.ll:8
 ; CHECK-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: br label %d
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %x = phi <2 x i8> [ <i8 1, i8 -1>, %a ], [ <i8 -1, i8 1>, %b ]
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 3 for instruction: %x = phi <2 x i8> [ <i8 1, i8 -1>, %a ], [ <i8 -1, i8 1>, %b ]
 ; CHECK-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: ret <2 x i8> %x
----------------
luke wrote:
> The generated code:
> ```
> f:                                      # @f
> 	.cfi_startproc
> # %bb.0:
> 	vsetivli	zero, 2, e8, mf8, ta, ma
> 	vid.v	v8
> 	andi	a0, a0, 1
> 	vadd.vv	v8, v8, v8
> 	beqz	a0, .LBB0_2
> # %bb.1:
> 	vrsub.vi	v8, v8, 1
> 	ret
> .LBB0_2:                                # %b
> 	vadd.vi	v8, v8, -1
> 	ret
> ```
I have one concern here about loops. In the loop we need to account for the materialization cost only once, if the input constant is a live-in. So for such values better to consider it free, I assume.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D149169/new/

https://reviews.llvm.org/D149169



More information about the llvm-commits mailing list