Open Quuxplusone opened 7 years ago
Bugzilla Link | PR30990 |
Status | NEW |
Importance | P normal |
Reported by | Carrot (carrot@google.com) |
Reported on | 2016-11-11 17:32:53 -0800 |
Last modified on | 2019-09-26 01:50:15 -0700 |
Version | trunk |
Hardware | PC Linux |
CC | ehsanamiri@gmail.com, fwage73@gmail.com, hfinkel@anl.gov, kit.barton@gmail.com, llvm-bugs@lists.llvm.org, mkuper@google.com, nemanja.i.ibm@gmail.com, spatel+llvm@rotateright.com |
Fixed by commit(s) | |
Attachments | |
Blocks | |
Blocked by | |
See also |
Looks like a problem in PPCTTIImpl::getMemoryOpCost, when load a type
<4 x i8>
The cost is 41.
When VF == 4, MemVT == MVT::v4i8, ValVT == MVT::v16i8,
function getLoadExtAction returns Expand, so getMemoryOpCost tries to compute
the cost of building a vector from scalar value, that is too high.
Actually VSX has lxsiwax which can load 32 bit value to VSX register. So I add
following code to PPCTargetLowering::PPCTargetLowering()
setLoadExtAction(ISD::EXTLOAD, MVT::v16i8, MVT::v4i8, Custom);
Then llvm can vectorize the loop, with -fno-unroll-loops option, now it
generates:
.LBB0_4: # %vector.body
# =>This Inner Loop Header: Depth=1
lxsiwax 37, 0, 3
lxvd2x 0, 0, 9
addi 10, 10, -4
addi 3, 3, 4
cmpldi 10, 0
xxspltw 37, 37, 1
xxswapd 32, 0
vcmpgtsb 5, 2, 5
vperm 5, 5, 5, 0
xxland 37, 37, 36
vadduwm 3, 5, 3
bne 0, .LBB0_4
...
There is still a problem, VSX instructions can handle 16 bytes in each
instruction, why doesn't vectorizer try vector factor 16?
Because the widest type in the loop is 32 bits wide.
Passing -vectorizer-maximize-bandwidth will vectorize by 16.
I've started working on making -vectorizer-maximize-bandwidth the default, but
it keeps getting pushed towards the bottom of my todo list.