Open Quuxplusone opened 4 years ago
Bugzilla Link | PR46968 |
Status | NEW |
Importance | P enhancement |
Reported by | David Bolvansky (david.bolvansky@gmail.com) |
Reported on | 2020-08-03 07:48:28 -0700 |
Last modified on | 2020-12-13 07:35:59 -0800 |
Version | trunk |
Hardware | PC Linux |
CC | craig.topper@gmail.com, florian_hahn@apple.com, hideki.saito@intel.com, llvm-bugs@lists.llvm.org, llvm-dev@redking.me.uk, spatel+llvm@rotateright.com |
Fixed by commit(s) | |
Attachments | |
Blocks | |
Blocked by | PR46983 |
See also | PR46915 |
I'll take a look at this
This snippet requires a uint3 vectorization of the RGB components, followed by
a umax reduction of the uint3 result for the A component.
Even before getting that to work, the more basic uint4 pattern fails to
vectorize:
components[B8G8R8A8_COMPONENT_BYTEOFFSET_*] =
umin((specularNHi * components[B8G8R8A8_COMPONENT_BYTEOFFSET_*]) >>
sOutputIntPrecisionBits,
255U);
Similar code:
#include<stdint.h>
#include<stddef.h>
const ptrdiff_t B8G8R8A8_COMPONENT_BYTEOFFSET_B = 0;
const ptrdiff_t B8G8R8A8_COMPONENT_BYTEOFFSET_G = 1;
const ptrdiff_t B8G8R8A8_COMPONENT_BYTEOFFSET_R = 2;
const ptrdiff_t B8G8R8A8_COMPONENT_BYTEOFFSET_A = 3;
struct Color
{
float r, g, b, a;
};
uint32_t ColorToBGRA(const Color& aColor)
{
union {
uint32_t color;
uint8_t components[4];
};
components[B8G8R8A8_COMPONENT_BYTEOFFSET_R] = uint8_t(aColor.r * aColor.a * 255.0f);
components[B8G8R8A8_COMPONENT_BYTEOFFSET_G] = uint8_t(aColor.g * aColor.a * 255.0f);
components[B8G8R8A8_COMPONENT_BYTEOFFSET_B] = uint8_t(aColor.b * aColor.a * 255.0f);
components[B8G8R8A8_COMPONENT_BYTEOFFSET_A] = uint8_t(aColor.a * 255.0f);
return color;
}
Not vectorized with generic x86 target.
https://godbolt.org/z/b1nz3K
“the more basic uint4 pattern fails to vectorize”
Fixed by Anton in trunk.