This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/40073] Vector short/char shifts generate sub-optimal code
- From: "segher at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 02 Mar 2017 10:26:28 +0000
- Subject: [Bug tree-optimization/40073] Vector short/char shifts generate sub-optimal code
- Auto-submitted: auto-generated
- References: <bug-40073-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=40073
Segher Boessenkool <segher at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |segher at gcc dot gnu.org
--- Comment #10 from Segher Boessenkool <segher at gcc dot gnu.org> ---
The shifts done as "int" are defined for shift values 0..31, while the
shifts done as "short int" are only defined for 0..15. Defining those
for 16..31 in the natural way (0, except shift right signed is -1 if
the input was negative) makes it possible to just shift in the smaller
mode. But machine insns like PowerPC vslb or vslh do not work that
way, so it will need to be expanded in a slightly trickier way, say
(input in vA, vB, short int case):
vspltib vZ,0 ; vspltib vO,-1
vslh vA,vA,vB
vpkuhum vB,vB,vB
vmrghb vB,vB,vB
vperm vT,vO,vZ,vB
vand vA,vA,vT
Or, split vB into three parts:
vspltih vE,1
vsrh vB1,vB,vE ; vand vB,vB,vE
vslh vA,vA,vB1 ; vslh vA,vA,vB1 ; vslh vA,vA,vB
(I hope I did that correctly; untested.)