Fix AArch64 ABI conformance issue in SIMD code.

In the AArch64 ABI, the high (unused) DWORD of a 32-bit argument's
register is undefined, so it was incorrect to use 64-bit instructions
to transfer a JDIMENSION argument in the 64-bit NEON SIMD functions.
The code worked thus far only because the existing compiler optimizers
weren't smart enough to do anything else with the register in question,
so the upper 32 bits happened to be all zeroes.

The latest builds of Clang/LLVM have a smarter optimizer, and under
certain circumstances, it will attempt to load-combine adjacent 32-bit
integers from one of the libjpeg structures into a single 64-bit integer
and pass that 64-bit integer as a 32-bit argument to one of the SIMD
functions (which is allowed by the ABI, since the upper 32 bits of the
32-bit argument's register are undefined.)  This caused the
libjpeg-turbo regression tests to crash.

This patch tries to use the Wn registers whenever possible.  Otherwise,
it uses a zero-extend instruction to avoid using the upper 32 bits of
the 64-bit registers, which are not guaranteed to be valid for 32-bit
arguments.

Based on sebpop@1fbae13

Closes #91.  Refer also to android-ndk/ndk#110 and
https://llvm.org/bugs/show_bug.cgi?id=28393

(cherrypick from external/libjpeg-turbo of c8282be605a139b269f2b8f4b4fb6f4118e740ab.)

Change-Id: I935a3696106e7ffcf9b1a6c12cb7f31d95b4ccc8
1 file changed
tree: 6087083c35131860fa72456a56e20c03ecd8f881
  1. Android.mk
  2. ansi2knr.1
  3. ansi2knr.c
  4. armv6_idct.S
  5. cderror.h
  6. cdjpeg.c
  7. cdjpeg.h
  8. change.log
  9. cjpeg.1
  10. cjpeg.c
  11. ckconfig.c
  12. CleanSpec.mk
  13. coderules.doc
  14. config.guess
  15. config.sub
  16. configure
  17. djpeg.1
  18. djpeg.c
  19. example.c
  20. filelist.doc
  21. install-sh
  22. install.doc
  23. jcapimin.c
  24. jcapistd.c
  25. jccoefct.c
  26. jccolor.c
  27. jcdctmgr.c
  28. jchuff.c
  29. jchuff.h
  30. jcinit.c
  31. jcmainct.c
  32. jcmarker.c
  33. jcmaster.c
  34. jcomapi.c
  35. jconfig.bcc
  36. jconfig.cfg
  37. jconfig.dj
  38. jconfig.doc
  39. jconfig.h
  40. jconfig.mac
  41. jconfig.manx
  42. jconfig.mc6
  43. jconfig.sas
  44. jconfig.st
  45. jconfig.vc
  46. jconfig.vms
  47. jconfig.wat
  48. jcparam.c
  49. jcphuff.c
  50. jcprepct.c
  51. jcsample.c
  52. jctrans.c
  53. jdapimin.c
  54. jdapistd.c
  55. jdatadst.c
  56. jdatasrc.c
  57. jdcoefct.c
  58. jdcolor.c
  59. jdct.h
  60. jddctmgr.c
  61. jdhuff.c
  62. jdhuff.h
  63. jdinput.c
  64. jdmainct.c
  65. jdmarker.c
  66. jdmaster.c
  67. jdmerge.c
  68. jdphuff.c
  69. jdpostct.c
  70. jdsample.c
  71. jdtrans.c
  72. jerror.c
  73. jerror.h
  74. jfdctflt.c
  75. jfdctfst.c
  76. jfdctint.c
  77. jidctflt.c
  78. jidctfst.c
  79. jidctint.c
  80. jidctintelsse.c
  81. jidctred.c
  82. jinclude.h
  83. jmemansi.c
  84. jmemdos.c
  85. jmemdosa.asm
  86. jmemmac.c
  87. jmemmgr.c
  88. jmemname.c
  89. jmemnobs.c
  90. jmemsys.h
  91. jmorecfg.h
  92. jpegint.h
  93. jpeglib.h
  94. jpegtran.1
  95. jpegtran.c
  96. jquant1.c
  97. jquant2.c
  98. jsimd_arm64_neon.S
  99. jsimd_arm_neon.S
  100. jsimd_neon.c
  101. jsimd_neon.h
  102. jutils.c
  103. jversion.h
  104. libjpeg.doc
  105. ltconfig
  106. ltmain.sh
  107. makcjpeg.st
  108. makdjpeg.st
  109. makeapps.ds
  110. makefile.ansi
  111. makefile.bcc
  112. makefile.cfg
  113. makefile.dj
  114. makefile.manx
  115. makefile.mc6
  116. makefile.mms
  117. makefile.sas
  118. makefile.unix
  119. makefile.vc
  120. makefile.vms
  121. makefile.wat
  122. makelib.ds
  123. makeproj.mac
  124. makljpeg.st
  125. maktjpeg.st
  126. makvms.opt
  127. mips_idct_le.S
  128. mips_jidctfst.c
  129. MODULE_LICENSE_BSD_LIKE
  130. NOTICE
  131. rdbmp.c
  132. rdcolmap.c
  133. rdgif.c
  134. rdjpgcom.1
  135. rdjpgcom.c
  136. rdppm.c
  137. rdrle.c
  138. rdswitch.c
  139. rdtarga.c
  140. README
  141. structure.doc
  142. testimg.bmp
  143. testimg.jpg
  144. testimg.ppm
  145. testimgp.jpg
  146. testorig.jpg
  147. testprog.jpg
  148. transupp.c
  149. transupp.h
  150. usage.doc
  151. wizard.doc
  152. wrbmp.c
  153. wrgif.c
  154. wrjpgcom.1
  155. wrjpgcom.c
  156. wrppm.c
  157. wrrle.c
  158. wrtarga.c