[PATCH] D38085: Use the basic cost if a GEP is not used as addressing mode
Eli Friedman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 20 12:04:05 PDT 2017
efriedma added inline comments.
================
Comment at: test/Analysis/CostModel/X86/vector_gep.ll:11
%vector = shufflevector <4 x i64> %temp, <4 x i64> undef, <4 x i32> zeroinitializer
-;CHECK: cost of 0 for instruction: {{.*}} getelementptr inbounds %struct.S
+;CHECK: cost of 1 for instruction: {{.*}} getelementptr inbounds %struct.S
%B = getelementptr inbounds %struct.S, <4 x %struct.S*> %s, <4 x i32> zeroinitializer, <4 x i32> zeroinitializer
----------------
junbuml wrote:
> With this patch, %B is changed to a non-free because it's used in %arrayidx (non-memory operation). It might be possible to continue checking users of the non-memory operation users, but doing this completely must be expensive to be done in getGEPCost. It might be possible to add some simple exceptions, but in this patch I didn't add such checks.
Yes, it should be fine to avoid folding together GEPs in getUserCost(). (Arguably, you might want to, but it could get complicated, so okay to skip that for now.)
That said, there's something going wrong here. "gep %x, 0, 0" is free because it's just a type conversion. By the same reasoning, "gep %s, zeroinitializer, zeroinitializer" should also be free.
https://reviews.llvm.org/D38085
More information about the llvm-commits
mailing list