Debian Codegraph @

gcc/testsuite/g++.target/i386/pr100885.C

raw
1 /* { dg-do compile { target { ! ia32 } } } */
2 /* { dg-options "-mavx512vl -mno-avx512bw -O2 -Wno-int-to-pointer-cast -std=c++14" } */
3 /* { dg-skip-if "requires hosted libstdc++ for cstdlib malloc" { ! hostedlib } } */
4
5 #include<x86intrin.h>
6 typedef unsigned char byte;
7 enum ZoomLevel { ZOOM_LVL_COUNT };
8 struct Colour {
9 unsigned data;
10 Colour(int data) : data(data) {}
11 };
12 struct Palette {
13 Colour palette[6];
14 };
15 enum BlitterMode { BM_COLOUR_REMAP };
16 class Blitter {
17 public:
18 struct BlitterParams {
19 int width;
20 int height;
21 int left;
22 int top;
23 void *dst;
24 };
25 virtual void Draw();
26 };
27 class Blitter_32bppAnim : public Blitter {
28 protected:
29 unsigned short anim_buf;
30 Palette palette;
31 int LookupColourInPalette_index;
32 Colour LookupColourInPalette() {
33 return palette.palette[LookupColourInPalette_index];
34 }
35 };
36 __m128i _mm_set_epi64(__m64 __q0) {
37 __m128i __trans_tmp_5{(long long)__q0};
38 return __trans_tmp_5;
39 }
40 long _mm_storel_epi64___P, Draw_dsts;
41 __m128i _mm_packus_epi16___B, _mm_subs_epu16___B, _mm_hadd_epi16___Y,
42 Draw_srcABCD, Draw___trans_tmp_10, Draw___trans_tmp_29, Draw___trans_tmp_7,
43 AlphaBlendTwoPixels___trans_tmp_12, AlphaBlendTwoPixels___trans_tmp_11,
44 AdjustBrightnessOfTwoPixels_from;
45 int _mm_srli_epi16___B;
46 class Blitter_32bppSSE_Base {
47 public:
48 enum ReadMode { RM_WITH_MARGIN };
49 enum BlockType { BT_NONE };
50 struct SpriteData {
51 int infos[ZOOM_LVL_COUNT];
52 byte data;
53 };
54 };
55 byte *Draw_remap;
56 short Draw_si_0;
57 class Blitter_32bppSSE4_Anim : Blitter_32bppAnim, Blitter_32bppSSE_Base {
58 template <BlitterMode, ReadMode, BlockType, bool, bool>
59 void Draw(const BlitterParams *, ZoomLevel);
60 void Draw();
61 };
62 __m128i AdjustBrightnessOfTwoPixels() {
63 __m128i __trans_tmp_28, __trans_tmp_27, __trans_tmp_26, __trans_tmp_24,
64 __trans_tmp_23, __trans_tmp_22, __trans_tmp_21, __trans_tmp_20,
65 __trans_tmp_19, __trans_tmp_18, __trans_tmp_17, __trans_tmp_16,
66 __trans_tmp_14 = _mm_srli_epi16(AdjustBrightnessOfTwoPixels_from,
67 _mm_srli_epi16___B),
68 __trans_tmp_7;
69 char __trans_tmp_8;
70 __trans_tmp_7 = __m128i{__trans_tmp_8};
71 {
72 __m128i __trans_tmp_7;
73 char __trans_tmp_8;
74 __trans_tmp_7 = __m128i{__trans_tmp_8};
75 __trans_tmp_26 = __trans_tmp_7;
76 }
77 __trans_tmp_16 = (__v8hi)__trans_tmp_14 > (__v8hi)__trans_tmp_26;
78 __trans_tmp_17 = _mm_hadd_epi16(__trans_tmp_16, _mm_hadd_epi16___Y);
79 __trans_tmp_18 = _mm_hadd_epi16(__trans_tmp_17, _mm_hadd_epi16___Y);
80 __trans_tmp_19 = _mm_srli_epi16(__trans_tmp_18, _mm_srli_epi16___B);
81 {
82 __m128i __trans_tmp_7;
83 char __trans_tmp_8;
84 __trans_tmp_7 = __m128i{__trans_tmp_8};
85 __trans_tmp_27 = __trans_tmp_7;
86 }
87 __trans_tmp_20 = _mm_shuffle_epi8(__trans_tmp_19,
88 __trans_tmp_27);
89 {
90 __m128i __trans_tmp_7;
91 char __trans_tmp_8;
92 __trans_tmp_7 = __m128i{__trans_tmp_8};
93 __trans_tmp_28 = __trans_tmp_7;
94 }
95 __trans_tmp_21 = _mm_subs_epu16(__trans_tmp_28, _mm_subs_epu16___B);
96 __trans_tmp_22 = __m128i((__v8hu)__trans_tmp_21 * (__v8hu)__trans_tmp_20);
97 __trans_tmp_23 = __m128i((__v8hu)__trans_tmp_22 + (__v8hu)__trans_tmp_7);
98 __trans_tmp_24 = _mm_packus_epi16(__trans_tmp_23, _mm_packus_epi16___B);
99 return __trans_tmp_24;
100 }
101 template <BlitterMode, Blitter_32bppSSE_Base::ReadMode,
102 Blitter_32bppSSE_Base::BlockType, bool, bool>
103 void Blitter_32bppSSE4_Anim::Draw(const BlitterParams *bp, ZoomLevel zoom) {
104 __m128i __trans_tmp_30;
105 Colour *dst_line = (Colour *)bp->dst + bp->left;
106 unsigned short *anim_line = &anim_buf + bp->top;
107 int effective_width;
108 SpriteData *sd = (SpriteData *)bp;
109 Colour *src_rgba_line = (Colour *)sd->data;
110 Draw___trans_tmp_29 = Draw___trans_tmp_7;
111 for (int y = bp->height; y; y--) {
112 Colour *dst = dst_line;
113 unsigned short *anim = anim_line;
114 anim += src_rgba_line[0].data;
115 dst += src_rgba_line[0].data;
116 int width_diff = Draw_si_0 - bp->width;
117 effective_width = width_diff ?: effective_width;
118 for (int x = effective_width; x; x--) {
119 int mvX2 = *(unsigned *)sd->infos[zoom], m = byte(mvX2);
120 __trans_tmp_30 = _mm_set_epi64(*(__m64_u *)dst);
121 Colour c0 = Draw_dsts, srcm(0), cmap = LookupColourInPalette().data & 40;
122 c0 = Draw_remap[m] ?: cmap;
123 c0 = m ? c0 : srcm;
124 Draw___trans_tmp_10 = __v2di{c0.data};
125 if (mvX2)
126 Draw_srcABCD = AdjustBrightnessOfTwoPixels();
127 if (src_rgba_line)
128 anim[1] = 0;
129 __m128i tmp;
130 __m128i dstAB = _mm_unpacklo_epi8(__trans_tmp_30, tmp);
131 AlphaBlendTwoPixels___trans_tmp_12 =
132 __m128i((__v8hu)Draw_srcABCD + (__v8hu)dstAB);
133 AlphaBlendTwoPixels___trans_tmp_11 = _mm_shuffle_epi8 (AlphaBlendTwoPixels___trans_tmp_12,
134 Draw___trans_tmp_7);
135 *(__m64_u *)_mm_storel_epi64___P =
136 (__m64)AlphaBlendTwoPixels___trans_tmp_11[0];
137 }
138 }
139 }
140 Blitter::BlitterParams Draw_bp;
141 ZoomLevel Draw_zoom;
142 void Blitter_32bppSSE4_Anim::Draw() {
143 Draw<BM_COLOUR_REMAP, RM_WITH_MARGIN, BT_NONE, true, false>(&Draw_bp,
144 Draw_zoom);
145 }