VSX has an instruction lxsiwax that can load 32bit value into VSX register. That patch makes it known to memory cost model, so the vectorization of the test case in pr30990 is beneficial.
Details
Diff Detail
Event Timeline
lib/Target/PowerPC/PPCISelLowering.cpp | ||
---|---|---|
680 ↗ | (On Diff #78092) | Is there more to this patch? Taking a quick look in PPCISelLowering.cpp, I don't see which custom lowering function will be invoked that will actually handle this node. Of course, it's entirely possible that I just missed it. |
lib/Target/PowerPC/PPCISelLowering.cpp | ||
---|---|---|
680 ↗ | (On Diff #78092) | You didn't miss anything. In lowering phase, it is translated to following SDNode And after LegalizeTypes(), t48: i32,ch = load<LD4[%lsr.iv16](align=1)(tbaa=<0xa868c68>)> t0, t2, undef:i64 t49: v4i32 = scalar_to_vector t48 t50: v16i8 = bitcast t49 And then it is directly translated to LXSIWAX. |
lib/Target/PowerPC/PPCISelLowering.cpp | ||
---|---|---|
680 ↗ | (On Diff #78092) | I see, legalization eliminates this illegal type and this patch just serves to provide a better answer when TTI checks if this is "LegalOrCustom" so that the vectorizer does not consider this too expensive to be profitable. |
lib/Target/PowerPC/PPCISelLowering.cpp | ||
---|---|---|
681–683 ↗ | (On Diff #78424) | Now that we are fixing this for v4i8, is it possible to fix this for some other vector types if a similar fix makes sense for them? For example does it make sense to make a similar change for v4i16 or v2i16 as well? |
This is certainly a novel use of setLoadExtAction for an illegal type ;) -- I worry that this is a bit hacky and not a technique we can use universally regardless. My inclination is that putting logic into PPCTargetTransformInfo would be better. X86TargetTransformInfo certainly has its fair share of cost tables, etc. to handle various situations the generic cost logic doesn't get quite right. I'm certainly open to hearing other opinions.
Please also directly add a cost-model test (e.g. to test/Analysis/CostModel/PowerPC/load_store.ll). With that, this LGTM.