1 Star 0 Fork 128

cenhuilin/gcc

forked from src-openEuler/gcc 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
LoongArch-Add-tests-for-SX-vector-vavg-vavgr-instruc.patch 70.97 KB
一键复制 编辑 原始数据 按行查看 历史
ticat_fp 提交于 2024-03-26 09:26 . LoongArch: update from gcc upstream
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375
From 4fba531ee417a29234e8be84e17cddc7dd9ec343 Mon Sep 17 00:00:00 2001
From: Xiaolong Chen <[email protected]>
Date: Mon, 11 Sep 2023 18:35:55 +0800
Subject: [PATCH 084/124] LoongArch: Add tests for SX vector vavg/vavgr
instructions.
gcc/testsuite/ChangeLog:
* gcc.target/loongarch/vector/lsx/lsx-vavg-1.c: New test.
* gcc.target/loongarch/vector/lsx/lsx-vavg-2.c: New test.
* gcc.target/loongarch/vector/lsx/lsx-vavgr-1.c: New test.
* gcc.target/loongarch/vector/lsx/lsx-vavgr-2.c: New test.
Signed-off-by: Peng Fan <[email protected]>
Signed-off-by: ticat_fp <[email protected]>
---
.../loongarch/vector/lsx/lsx-vavg-1.c | 398 ++++++++++++++++++
.../loongarch/vector/lsx/lsx-vavg-2.c | 308 ++++++++++++++
.../loongarch/vector/lsx/lsx-vavgr-1.c | 299 +++++++++++++
.../loongarch/vector/lsx/lsx-vavgr-2.c | 317 ++++++++++++++
4 files changed, 1322 insertions(+)
create mode 100644 gcc/testsuite/gcc.target/loongarch/vector/lsx/lsx-vavg-1.c
create mode 100644 gcc/testsuite/gcc.target/loongarch/vector/lsx/lsx-vavg-2.c
create mode 100644 gcc/testsuite/gcc.target/loongarch/vector/lsx/lsx-vavgr-1.c
create mode 100644 gcc/testsuite/gcc.target/loongarch/vector/lsx/lsx-vavgr-2.c
diff --git a/gcc/testsuite/gcc.target/loongarch/vector/lsx/lsx-vavg-1.c b/gcc/testsuite/gcc.target/loongarch/vector/lsx/lsx-vavg-1.c
new file mode 100644
index 000000000..2177ca3f6
--- /dev/null
+++ b/gcc/testsuite/gcc.target/loongarch/vector/lsx/lsx-vavg-1.c
@@ -0,0 +1,398 @@
+/* { dg-do run } */
+/* { dg-options "-mlsx -w -fno-strict-aliasing" } */
+#include "../simd_correctness_check.h"
+#include <lsxintrin.h>
+
+int
+main ()
+{
+ __m128i __m128i_op0, __m128i_op1, __m128i_op2, __m128i_out, __m128i_result;
+ __m128 __m128_op0, __m128_op1, __m128_op2, __m128_out, __m128_result;
+ __m128d __m128d_op0, __m128d_op1, __m128d_op2, __m128d_out, __m128d_result;
+
+ int int_op0, int_op1, int_op2, int_out, int_result, i = 1, fail;
+ long int long_op0, long_op1, long_op2, lont_out, lont_result;
+ long int long_int_out, long_int_result;
+ unsigned int unsigned_int_out, unsigned_int_result;
+ unsigned long int unsigned_long_int_out, unsigned_long_int_result;
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[0]) = 0x0000000000000000;
+ __m128i_out = __lsx_vavg_b (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0xfff8fff8fff8fff8;
+ *((unsigned long *)&__m128i_op0[0]) = 0xfff8fff8fff8fff8;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[1]) = 0xfffcfffcfffcfffc;
+ *((unsigned long *)&__m128i_result[0]) = 0xfffcfffcfffcfffc;
+ __m128i_out = __lsx_vavg_b (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[0]) = 0x0000000000000000;
+ __m128i_out = __lsx_vavg_b (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[0]) = 0x0000000000000000;
+ __m128i_out = __lsx_vavg_b (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0xffffffffffffffff;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x4050000000000000;
+ *((unsigned long *)&__m128i_result[1]) = 0xffffffffffffffff;
+ *((unsigned long *)&__m128i_result[0]) = 0x2028000000000000;
+ __m128i_out = __lsx_vavg_b (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[0]) = 0x0000000000000000;
+ __m128i_out = __lsx_vavg_b (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0xffffffffffffffff;
+ *((unsigned long *)&__m128i_op1[0]) = 0xffffffffffffffff;
+ *((unsigned long *)&__m128i_result[1]) = 0xffffffffffffffff;
+ *((unsigned long *)&__m128i_result[0]) = 0xffffffffffffffff;
+ __m128i_out = __lsx_vavg_b (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[0]) = 0x0000000000000000;
+ __m128i_out = __lsx_vavg_b (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x67eb85afb2ebb000;
+ *((unsigned long *)&__m128i_op0[0]) = 0xc8847ef6ed3f2000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000000014155445;
+ *((unsigned long *)&__m128i_result[1]) = 0x33f5c2d7d9f5d800;
+ *((unsigned long *)&__m128i_result[0]) = 0xe4c23ffb002a3a22;
+ __m128i_out = __lsx_vavg_b (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[0]) = 0x0000000000000000;
+ __m128i_out = __lsx_vavg_b (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[0]) = 0x0000000000000000;
+ __m128i_out = __lsx_vavg_h (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x007fffff00000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x00000000000f000e;
+ *((unsigned long *)&__m128i_op1[0]) = 0x00000000000ffffe;
+ *((unsigned long *)&__m128i_result[1]) = 0x003fffff00070007;
+ *((unsigned long *)&__m128i_result[0]) = 0x000000000007ffff;
+ __m128i_out = __lsx_vavg_h (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[0]) = 0x0000000000000000;
+ __m128i_out = __lsx_vavg_h (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000040;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000040;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000400028000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000000000000004;
+ *((unsigned long *)&__m128i_result[1]) = 0x000000020001c020;
+ *((unsigned long *)&__m128i_result[0]) = 0x0000000000000022;
+ __m128i_out = __lsx_vavg_h (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x08080807f5f5f5f8;
+ *((unsigned long *)&__m128i_op1[0]) = 0x000000000000ff00;
+ *((unsigned long *)&__m128i_result[1]) = 0x04040403fafafafc;
+ *((unsigned long *)&__m128i_result[0]) = 0x000000000000ff80;
+ __m128i_out = __lsx_vavg_h (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x10f8000100000001;
+ *((unsigned long *)&__m128i_op0[0]) = 0x00000001000010f8;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[1]) = 0x087c000000000000;
+ *((unsigned long *)&__m128i_result[0]) = 0x000000000000087c;
+ __m128i_out = __lsx_vavg_h (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[0]) = 0x0000000000000000;
+ __m128i_out = __lsx_vavg_w (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x5641127843c0d41e;
+ *((unsigned long *)&__m128i_op0[0]) = 0xfedb27095b6bff95;
+ *((unsigned long *)&__m128i_op1[1]) = 0xa8beed87bc3f2be1;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0024d8f6a494006a;
+ *((unsigned long *)&__m128i_result[1]) = 0xff7fffffffffffff;
+ *((unsigned long *)&__m128i_result[0]) = 0xff7fffffffffffff;
+ __m128i_out = __lsx_vavg_w (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x000000000000ffff;
+ *((unsigned long *)&__m128i_op1[1]) = 0xffffffffffffffff;
+ *((unsigned long *)&__m128i_op1[0]) = 0xffffffffffffffff;
+ *((unsigned long *)&__m128i_result[1]) = 0xffffffffffffffff;
+ *((unsigned long *)&__m128i_result[0]) = 0xffffffff00007fff;
+ __m128i_out = __lsx_vavg_w (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0xffff80ff0010ff06;
+ *((unsigned long *)&__m128i_op0[0]) = 0x8000000080000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0xedfaedfaedfaedfa;
+ *((unsigned long *)&__m128i_op1[0]) = 0x00000000ffff0000;
+ *((unsigned long *)&__m128i_result[1]) = 0xf6fd377cf705f680;
+ *((unsigned long *)&__m128i_result[0]) = 0xc0000000bfff8000;
+ __m128i_out = __lsx_vavg_w (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x3ff0000000007fff;
+ *((unsigned long *)&__m128i_op0[0]) = 0x000000002bfd9461;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000f00;
+ *((unsigned long *)&__m128i_op1[0]) = 0x00000000ffffff00;
+ *((unsigned long *)&__m128i_result[1]) = 0x1ff800000000477f;
+ *((unsigned long *)&__m128i_result[0]) = 0x0000000015fec9b0;
+ __m128i_out = __lsx_vavg_w (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x000000000000006f;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[1]) = 0x0000000000000037;
+ *((unsigned long *)&__m128i_result[0]) = 0x0000000000000000;
+ __m128i_out = __lsx_vavg_w (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[0]) = 0x0000000000000000;
+ __m128i_out = __lsx_vavg_w (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x003fffff00000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x003fffff00000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x003fffff00000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x003fffff00000000;
+ *((unsigned long *)&__m128i_result[1]) = 0x003fffff00000000;
+ *((unsigned long *)&__m128i_result[0]) = 0x003fffff00000000;
+ __m128i_out = __lsx_vavg_w (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[0]) = 0x0000000000000000;
+ __m128i_out = __lsx_vavg_w (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0001000100010001;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0001000100010001;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[1]) = 0x0000800000008000;
+ *((unsigned long *)&__m128i_result[0]) = 0x0000800000008000;
+ __m128i_out = __lsx_vavg_w (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0xd6a09e662ab46b31;
+ *((unsigned long *)&__m128i_op0[0]) = 0x34b8122ef4054bb3;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[1]) = 0xeb504f33155a3598;
+ *((unsigned long *)&__m128i_result[0]) = 0x1a5c0917fa02a5d9;
+ __m128i_out = __lsx_vavg_w (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0177fff0fffffff0;
+ *((unsigned long *)&__m128i_op0[0]) = 0x00000000011ff8bc;
+ *((unsigned long *)&__m128i_op1[1]) = 0xffffffffffffffff;
+ *((unsigned long *)&__m128i_op1[0]) = 0xfffffffefffff784;
+ *((unsigned long *)&__m128i_result[1]) = 0x00bbfff7fffffff7;
+ *((unsigned long *)&__m128i_result[0]) = 0xffffffff008ff820;
+ __m128i_out = __lsx_vavg_w (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000001;
+ *((unsigned long *)&__m128i_op0[0]) = 0x00001802041b0014;
+ *((unsigned long *)&__m128i_op1[1]) = 0xffffffffffffffff;
+ *((unsigned long *)&__m128i_op1[0]) = 0xffffffffffffffff;
+ *((unsigned long *)&__m128i_result[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[0]) = 0x00000c01020d8009;
+ __m128i_out = __lsx_vavg_d (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000001;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000000000000001;
+ *((unsigned long *)&__m128i_result[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[0]) = 0x0000000000000000;
+ __m128i_out = __lsx_vavg_d (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x000201000000000b;
+ *((unsigned long *)&__m128i_op1[1]) = 0x00000000ffff0000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000000200000000;
+ *((unsigned long *)&__m128i_result[1]) = 0x000000007fff8000;
+ *((unsigned long *)&__m128i_result[0]) = 0x0001008100000005;
+ __m128i_out = __lsx_vavg_d (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0xfc01fd1300000001;
+ *((unsigned long *)&__m128i_op0[0]) = 0xfe00fd1400010000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x00000000fff7fc01;
+ *((unsigned long *)&__m128i_result[1]) = 0xfe00fe8980000000;
+ *((unsigned long *)&__m128i_result[0]) = 0xff007e8a7ffc7e00;
+ __m128i_out = __lsx_vavg_d (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000001;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[0]) = 0x0000000000000000;
+ __m128i_out = __lsx_vavg_d (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0xffffffffffffffff;
+ *((unsigned long *)&__m128i_op1[0]) = 0xffffffffffffffff;
+ *((unsigned long *)&__m128i_result[1]) = 0xffffffffffffffff;
+ *((unsigned long *)&__m128i_result[0]) = 0xffffffffffffffff;
+ __m128i_out = __lsx_vavg_d (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[0]) = 0x0000000000000000;
+ __m128i_out = __lsx_vavg_d (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0xffffffffffffffff;
+ *((unsigned long *)&__m128i_op0[0]) = 0xffffffffffffffff;
+ *((unsigned long *)&__m128i_op1[1]) = 0xfffffffe00000002;
+ *((unsigned long *)&__m128i_op1[0]) = 0xffffff46000000ba;
+ *((unsigned long *)&__m128i_result[1]) = 0xffffffff00000000;
+ *((unsigned long *)&__m128i_result[0]) = 0xffffffa30000005c;
+ __m128i_out = __lsx_vavg_d (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000070007;
+ *((unsigned long *)&__m128i_op0[0]) = 0x000000000007ffff;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000000000000068;
+ *((unsigned long *)&__m128i_result[1]) = 0x0000000000038003;
+ *((unsigned long *)&__m128i_result[0]) = 0x0000000000040033;
+ __m128i_out = __lsx_vavg_d (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0xffffffff0000ac26;
+ *((unsigned long *)&__m128i_op1[0]) = 0x00ff000000000001;
+ *((unsigned long *)&__m128i_result[1]) = 0xffffffff80005613;
+ *((unsigned long *)&__m128i_result[0]) = 0x007f800000000000;
+ __m128i_out = __lsx_vavg_d (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000040000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000040000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x7f8000007f800000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x7f8000007f800000;
+ *((unsigned long *)&__m128i_result[1]) = 0x3fc000005fc00000;
+ *((unsigned long *)&__m128i_result[0]) = 0x3fc000005fc00000;
+ __m128i_out = __lsx_vavg_d (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000020000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[1]) = 0x0000000000010000;
+ *((unsigned long *)&__m128i_result[0]) = 0x0000000000000000;
+ __m128i_out = __lsx_vavg_d (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000200000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0002000200000001;
+ *((unsigned long *)&__m128i_result[1]) = 0x0000000100000000;
+ *((unsigned long *)&__m128i_result[0]) = 0x0001000100000000;
+ __m128i_out = __lsx_vavg_d (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0xffffffff00000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0xffffffff00000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x00000000fffe0001;
+ *((unsigned long *)&__m128i_op1[0]) = 0xffffffff0001fffe;
+ *((unsigned long *)&__m128i_result[1]) = 0xffffffffffff0000;
+ *((unsigned long *)&__m128i_result[0]) = 0xffffffff0000ffff;
+ __m128i_out = __lsx_vavg_d (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.target/loongarch/vector/lsx/lsx-vavg-2.c b/gcc/testsuite/gcc.target/loongarch/vector/lsx/lsx-vavg-2.c
new file mode 100644
index 000000000..1b0d879e4
--- /dev/null
+++ b/gcc/testsuite/gcc.target/loongarch/vector/lsx/lsx-vavg-2.c
@@ -0,0 +1,308 @@
+/* { dg-do run } */
+/* { dg-options "-mlsx -w -fno-strict-aliasing" } */
+#include "../simd_correctness_check.h"
+#include <lsxintrin.h>
+
+int
+main ()
+{
+ __m128i __m128i_op0, __m128i_op1, __m128i_op2, __m128i_out, __m128i_result;
+ __m128 __m128_op0, __m128_op1, __m128_op2, __m128_out, __m128_result;
+ __m128d __m128d_op0, __m128d_op1, __m128d_op2, __m128d_out, __m128d_result;
+
+ int int_op0, int_op1, int_op2, int_out, int_result, i = 1, fail;
+ long int long_op0, long_op1, long_op2, lont_out, lont_result;
+ long int long_int_out, long_int_result;
+ unsigned int unsigned_int_out, unsigned_int_result;
+ unsigned long int unsigned_long_int_out, unsigned_long_int_result;
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000100000001;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[0]) = 0x0000000000000000;
+ __m128i_out = __lsx_vavg_bu (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0xffffffffffffffff;
+ *((unsigned long *)&__m128i_op1[0]) = 0xffffffffffffffff;
+ *((unsigned long *)&__m128i_result[1]) = 0x7f7f7f7f7f7f7f7f;
+ *((unsigned long *)&__m128i_result[0]) = 0x7f7f7f7f7f7f7f7f;
+ __m128i_out = __lsx_vavg_bu (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0xfffffffffffffffe;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0xffffffffffffffff;
+ *((unsigned long *)&__m128i_op1[0]) = 0xffffffffffffffff;
+ *((unsigned long *)&__m128i_result[1]) = 0xfffffffffffffffe;
+ *((unsigned long *)&__m128i_result[0]) = 0x7f7f7f7f7f7f7f7f;
+ __m128i_out = __lsx_vavg_bu (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0xffffffffffffffff;
+ *((unsigned long *)&__m128i_op0[0]) = 0xffffffffffffffff;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[1]) = 0x7f7f7f7f7f7f7f7f;
+ *((unsigned long *)&__m128i_result[0]) = 0x7f7f7f7f7f7f7f7f;
+ __m128i_out = __lsx_vavg_bu (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000100000001000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x37b951002d81a921;
+ *((unsigned long *)&__m128i_op1[1]) = 0x000000400000004c;
+ *((unsigned long *)&__m128i_op1[0]) = 0x000047404f4f040d;
+ *((unsigned long *)&__m128i_result[1]) = 0x0000082000000826;
+ *((unsigned long *)&__m128i_result[0]) = 0x1b5c4c203e685617;
+ __m128i_out = __lsx_vavg_bu (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x00c2758000bccf42;
+ *((unsigned long *)&__m128i_op0[0]) = 0x00a975be00accf03;
+ *((unsigned long *)&__m128i_op1[1]) = 0x00c2758000bccf42;
+ *((unsigned long *)&__m128i_op1[0]) = 0x00a975be00accf03;
+ *((unsigned long *)&__m128i_result[1]) = 0x00c2758000bccf42;
+ *((unsigned long *)&__m128i_result[0]) = 0x00a975be00accf03;
+ __m128i_out = __lsx_vavg_bu (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0100000001000100;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0100010000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0xffffffffffffffff;
+ *((unsigned long *)&__m128i_op1[0]) = 0xffffffffffff732a;
+ *((unsigned long *)&__m128i_result[1]) = 0x807f7fff807f807f;
+ *((unsigned long *)&__m128i_result[0]) = 0x807f807f7fff3995;
+ __m128i_out = __lsx_vavg_hu (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x000000007f7f7f7f;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0xfffffffffffffff0;
+ *((unsigned long *)&__m128i_result[1]) = 0x000000003fbf3fbf;
+ *((unsigned long *)&__m128i_result[0]) = 0x7fff7fff7fff7ff8;
+ __m128i_out = __lsx_vavg_hu (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0101010101010101;
+ *((unsigned long *)&__m128i_op0[0]) = 0x353c8cc4b1ec5b09;
+ *((unsigned long *)&__m128i_op1[1]) = 0xffff00000000ffff;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[1]) = 0x8080008000808080;
+ *((unsigned long *)&__m128i_result[0]) = 0x1a9e466258f62d84;
+ __m128i_out = __lsx_vavg_hu (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[0]) = 0x0000000000000000;
+ __m128i_out = __lsx_vavg_hu (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[0]) = 0x0000000000000000;
+ __m128i_out = __lsx_vavg_hu (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000000000000158;
+ *((unsigned long *)&__m128i_result[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[0]) = 0x00000000000000ac;
+ __m128i_out = __lsx_vavg_hu (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x9c9c9c9c00000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000000000000020;
+ *((unsigned long *)&__m128i_result[1]) = 0x4e4e4e4e00000000;
+ *((unsigned long *)&__m128i_result[0]) = 0x0000000000000010;
+ __m128i_out = __lsx_vavg_hu (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000868686868686;
+ *((unsigned long *)&__m128i_op1[1]) = 0x1e1e1e1e1e1e1e1e;
+ *((unsigned long *)&__m128i_op1[0]) = 0x1e1e1e1e1e1e1e1e;
+ *((unsigned long *)&__m128i_result[1]) = 0x0f0f0f0f0f0f0f0f;
+ *((unsigned long *)&__m128i_result[0]) = 0x0f0f525252525252;
+ __m128i_out = __lsx_vavg_hu (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000014eb54ab;
+ *((unsigned long *)&__m128i_op0[0]) = 0x14eb6a002a406a00;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x00000000ffdfdc0d;
+ *((unsigned long *)&__m128i_result[1]) = 0x000000000a752a55;
+ *((unsigned long *)&__m128i_result[0]) = 0x0a753500950fa306;
+ __m128i_out = __lsx_vavg_hu (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0xfffff00010000fff;
+ *((unsigned long *)&__m128i_op0[0]) = 0xfffff00010000fff;
+ *((unsigned long *)&__m128i_op1[1]) = 0xfffff00010000fff;
+ *((unsigned long *)&__m128i_op1[0]) = 0xfffff00010000fff;
+ *((unsigned long *)&__m128i_result[1]) = 0xfffff00010000fff;
+ *((unsigned long *)&__m128i_result[0]) = 0xfffff00010000fff;
+ __m128i_out = __lsx_vavg_wu (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x00000002ffffffff;
+ *((unsigned long *)&__m128i_result[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[0]) = 0x000000017fffffff;
+ __m128i_out = __lsx_vavg_wu (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0101000100010001;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0101030100010001;
+ *((unsigned long *)&__m128i_result[1]) = 0x0080800000008000;
+ *((unsigned long *)&__m128i_result[0]) = 0x0080818000008000;
+ __m128i_out = __lsx_vavg_wu (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000400000004;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000000400000004;
+ *((unsigned long *)&__m128i_result[1]) = 0x0000000200000002;
+ *((unsigned long *)&__m128i_result[0]) = 0x0000000200000002;
+ __m128i_out = __lsx_vavg_wu (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[0]) = 0x0000000000000000;
+ __m128i_out = __lsx_vavg_wu (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[0]) = 0x0000000000000000;
+ __m128i_out = __lsx_vavg_wu (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[0]) = 0x0000000000000000;
+ __m128i_out = __lsx_vavg_wu (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0017004800c400f9;
+ *((unsigned long *)&__m128i_op0[0]) = 0x00ed001a00580070;
+ *((unsigned long *)&__m128i_op1[1]) = 0xffffff7ffffffffe;
+ *((unsigned long *)&__m128i_op1[0]) = 0x00000000fffffffe;
+ *((unsigned long *)&__m128i_result[1]) = 0x800b7fe38062007b;
+ *((unsigned long *)&__m128i_result[0]) = 0x0076800d802c0037;
+ __m128i_out = __lsx_vavg_wu (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0xff80ffa2fff0ff74;
+ *((unsigned long *)&__m128i_op0[0]) = 0xff76ffd8ffe6ffaa;
+ *((unsigned long *)&__m128i_op1[1]) = 0xc0b4d1a5f8babad3;
+ *((unsigned long *)&__m128i_op1[0]) = 0xbbc8ecc5f3ced5f3;
+ *((unsigned long *)&__m128i_result[1]) = 0xe01ae8a3fc55dd23;
+ *((unsigned long *)&__m128i_result[0]) = 0xdd9ff64ef9daeace;
+ __m128i_out = __lsx_vavg_wu (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x00000000ffffffff;
+ *((unsigned long *)&__m128i_result[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[0]) = 0x000000007fffffff;
+ __m128i_out = __lsx_vavg_du (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x3f80000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x3f80000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000ff000000ff00;
+ *((unsigned long *)&__m128i_result[1]) = 0x1fc0000000000000;
+ *((unsigned long *)&__m128i_result[0]) = 0x1fc07f8000007f80;
+ __m128i_out = __lsx_vavg_du (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[0]) = 0x0000000000000000;
+ __m128i_out = __lsx_vavg_du (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[0]) = 0x0000000000000000;
+ __m128i_out = __lsx_vavg_du (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000001;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000001;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000043cf26c7;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000e31d4cae8636;
+ *((unsigned long *)&__m128i_result[1]) = 0x0000000021e79364;
+ *((unsigned long *)&__m128i_result[0]) = 0x0000718ea657431b;
+ __m128i_out = __lsx_vavg_du (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0xfff0000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0xfff0000000000000;
+ *((unsigned long *)&__m128i_result[1]) = 0x7ff8000000000000;
+ *((unsigned long *)&__m128i_result[0]) = 0x7ff8000000000000;
+ __m128i_out = __lsx_vavg_du (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[0]) = 0x0000000000000000;
+ __m128i_out = __lsx_vavg_du (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0xffffff80ffff7e02;
+ *((unsigned long *)&__m128i_op0[0]) = 0x00feff8000ff80ff;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000ffff0000ffff;
+ *((unsigned long *)&__m128i_op1[0]) = 0xf931fd04f832fe02;
+ *((unsigned long *)&__m128i_result[1]) = 0x80007fc000003f00;
+ *((unsigned long *)&__m128i_result[0]) = 0x7d187e427c993f80;
+ __m128i_out = __lsx_vavg_du (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.target/loongarch/vector/lsx/lsx-vavgr-1.c b/gcc/testsuite/gcc.target/loongarch/vector/lsx/lsx-vavgr-1.c
new file mode 100644
index 000000000..4b7262537
--- /dev/null
+++ b/gcc/testsuite/gcc.target/loongarch/vector/lsx/lsx-vavgr-1.c
@@ -0,0 +1,299 @@
+/* { dg-do run } */
+/* { dg-options "-mlsx -w -fno-strict-aliasing" } */
+#include "../simd_correctness_check.h"
+#include <lsxintrin.h>
+
+int
+main ()
+{
+ __m128i __m128i_op0, __m128i_op1, __m128i_op2, __m128i_out, __m128i_result;
+ __m128 __m128_op0, __m128_op1, __m128_op2, __m128_out, __m128_result;
+ __m128d __m128d_op0, __m128d_op1, __m128d_op2, __m128d_out, __m128d_result;
+
+ int int_op0, int_op1, int_op2, int_out, int_result, i = 1, fail;
+ long int long_op0, long_op1, long_op2, lont_out, lont_result;
+ long int long_int_out, long_int_result;
+ unsigned int unsigned_int_out, unsigned_int_result;
+ unsigned long int unsigned_long_int_out, unsigned_long_int_result;
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000800000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0040000000ff00ff;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0040000000000000;
+ *((unsigned long *)&__m128i_result[1]) = 0x0020000000000000;
+ *((unsigned long *)&__m128i_result[0]) = 0x0020c00000000000;
+ __m128i_out = __lsx_vavgr_b (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0xffffffffffffffff;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0xffffffffffffffff;
+ *((unsigned long *)&__m128i_op1[0]) = 0xffffffffffffffff;
+ *((unsigned long *)&__m128i_result[1]) = 0xffffffffffffffff;
+ *((unsigned long *)&__m128i_result[0]) = 0x0000000000000000;
+ __m128i_out = __lsx_vavgr_b (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0xb9fe3640e4eb1b18;
+ *((unsigned long *)&__m128i_op0[0]) = 0x800000005b4b1b18;
+ *((unsigned long *)&__m128i_op1[1]) = 0xfffd000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[1]) = 0xdcfe1b20f2f60e0c;
+ *((unsigned long *)&__m128i_result[0]) = 0xc00000002e260e0c;
+ __m128i_out = __lsx_vavgr_b (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x111110ff11111141;
+ *((unsigned long *)&__m128i_op0[0]) = 0x1111113111111121;
+ *((unsigned long *)&__m128i_op1[1]) = 0xfbffffffffffffff;
+ *((unsigned long *)&__m128i_op1[0]) = 0x7bffffffffffffff;
+ *((unsigned long *)&__m128i_result[1]) = 0x060808ff08080820;
+ *((unsigned long *)&__m128i_result[0]) = 0x4608081808080810;
+ __m128i_out = __lsx_vavgr_b (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x000000ff000000ff;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[0]) = 0x0000000000000000;
+ __m128i_out = __lsx_vavgr_b (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000010;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000010;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x000000000000fff0;
+ *((unsigned long *)&__m128i_result[1]) = 0x0000000000000008;
+ *((unsigned long *)&__m128i_result[0]) = 0x0000000000000000;
+ __m128i_out = __lsx_vavgr_b (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x000000000000ac26;
+ *((unsigned long *)&__m128i_op0[0]) = 0xffffffff80000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000060000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[1]) = 0x000003000000d613;
+ *((unsigned long *)&__m128i_result[0]) = 0x00000000c0000000;
+ __m128i_out = __lsx_vavgr_b (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[0]) = 0x0000000000000000;
+ __m128i_out = __lsx_vavgr_b (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0xffffffffffffffe5;
+ *((unsigned long *)&__m128i_op0[0]) = 0xffffffffffffffe5;
+ *((unsigned long *)&__m128i_op1[1]) = 0xffffffffffffffff;
+ *((unsigned long *)&__m128i_op1[0]) = 0xffffffffffffffff;
+ *((unsigned long *)&__m128i_result[1]) = 0xfffffffffffffff2;
+ *((unsigned long *)&__m128i_result[0]) = 0xfffffffffffffff2;
+ __m128i_out = __lsx_vavgr_h (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000073;
+ *((unsigned long *)&__m128i_op0[0]) = 0x000000000000002a;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000000100000000;
+ *((unsigned long *)&__m128i_result[1]) = 0x000000000000003a;
+ *((unsigned long *)&__m128i_result[0]) = 0x0000000100000015;
+ __m128i_out = __lsx_vavgr_h (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000004000;
+ *((unsigned long *)&__m128i_op1[0]) = 0xfff8004000000000;
+ *((unsigned long *)&__m128i_result[1]) = 0x0000000000002000;
+ *((unsigned long *)&__m128i_result[0]) = 0xfffc002000000000;
+ __m128i_out = __lsx_vavgr_w (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000002000;
+ *((unsigned long *)&__m128i_op0[0]) = 0xfffc002000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000002000;
+ *((unsigned long *)&__m128i_op1[0]) = 0xfffc002000000000;
+ *((unsigned long *)&__m128i_result[1]) = 0x0000000000002000;
+ *((unsigned long *)&__m128i_result[0]) = 0xfffc002000000000;
+ __m128i_out = __lsx_vavgr_w (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x000000ff00000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x000000ff00000000;
+ *((unsigned long *)&__m128i_result[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[0]) = 0x000000ff00000000;
+ __m128i_out = __lsx_vavgr_w (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x000000007fff0018;
+ *((unsigned long *)&__m128i_result[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[0]) = 0x000000003fff800c;
+ __m128i_out = __lsx_vavgr_w (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0xffffffffffffffff;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[0]) = 0x0000000000000000;
+ __m128i_out = __lsx_vavgr_w (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0280000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x7500000075000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x7500000075000000;
+ *((unsigned long *)&__m128i_result[1]) = 0x3a8000003a800000;
+ *((unsigned long *)&__m128i_result[0]) = 0x3bc000003a800000;
+ __m128i_out = __lsx_vavgr_w (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0xffff800000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x00007d1800007c99;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0a0000001e000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0a621b3ebe5e1c02;
+ *((unsigned long *)&__m128i_result[1]) = 0x04ffc0000f000000;
+ *((unsigned long *)&__m128i_result[0]) = 0x05314c2bdf2f4c4e;
+ __m128i_out = __lsx_vavgr_w (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000001;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000002000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000002000000000;
+ *((unsigned long *)&__m128i_result[1]) = 0x0000001000000001;
+ *((unsigned long *)&__m128i_result[0]) = 0x0000001000000000;
+ __m128i_out = __lsx_vavgr_w (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0xffffffff00000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[1]) = 0xffffffff80000000;
+ *((unsigned long *)&__m128i_result[0]) = 0x0000000000000000;
+ __m128i_out = __lsx_vavgr_d (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0xffffffffffffffff;
+ *((unsigned long *)&__m128i_op0[0]) = 0xffffffffffffffff;
+ *((unsigned long *)&__m128i_op1[1]) = 0x7f8000007f800000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x7f8000007f800000;
+ *((unsigned long *)&__m128i_result[1]) = 0x3fc000003fc00000;
+ *((unsigned long *)&__m128i_result[0]) = 0x3fc000003fc00000;
+ __m128i_out = __lsx_vavgr_d (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x7fffffff7fffffff;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[1]) = 0x3fffffffc0000000;
+ *((unsigned long *)&__m128i_result[0]) = 0x0000000000000000;
+ __m128i_out = __lsx_vavgr_d (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0xff00ff00ff00ff00;
+ *((unsigned long *)&__m128i_op1[0]) = 0xff00ff00ff00ff00;
+ *((unsigned long *)&__m128i_result[1]) = 0xff807f807f807f80;
+ *((unsigned long *)&__m128i_result[0]) = 0xff807f807f807f80;
+ __m128i_out = __lsx_vavgr_d (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000002;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000002;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000000000280000;
+ *((unsigned long *)&__m128i_result[1]) = 0x0000000000000001;
+ *((unsigned long *)&__m128i_result[0]) = 0x0000000000140001;
+ __m128i_out = __lsx_vavgr_d (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0xfffffffffffffffe;
+ *((unsigned long *)&__m128i_op0[0]) = 0xffffffffffffff46;
+ *((unsigned long *)&__m128i_op1[1]) = 0x00fe00fe00fe00fe;
+ *((unsigned long *)&__m128i_op1[0]) = 0x00fe00fe00fe0045;
+ *((unsigned long *)&__m128i_result[1]) = 0x007f007f007f007e;
+ *((unsigned long *)&__m128i_result[0]) = 0x007f007f007effc6;
+ __m128i_out = __lsx_vavgr_d (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[0]) = 0x0000000000000000;
+ __m128i_out = __lsx_vavgr_d (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[0]) = 0x0000000000000000;
+ __m128i_out = __lsx_vavgr_d (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x67eb85afb2ebb000;
+ *((unsigned long *)&__m128i_op0[0]) = 0xc8847ef6ed3f2000;
+ *((unsigned long *)&__m128i_op1[1]) = 0xfffffffffffffffc;
+ *((unsigned long *)&__m128i_op1[0]) = 0xfffffffffffffffc;
+ *((unsigned long *)&__m128i_result[1]) = 0x33f5c2d7d975d7fe;
+ *((unsigned long *)&__m128i_result[0]) = 0xe4423f7b769f8ffe;
+ __m128i_out = __lsx_vavgr_d (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[0]) = 0x0000000000000000;
+ __m128i_out = __lsx_vavgr_d (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000003ff8;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0xff9dff9dff9dff9d;
+ *((unsigned long *)&__m128i_result[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[0]) = 0xffceffceffcf1fcb;
+ __m128i_out = __lsx_vavgr_d (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x3a8000003a800000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x3bc000003a800000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x00fe00fe7fffffff;
+ *((unsigned long *)&__m128i_result[1]) = 0x1d4000001d400000;
+ *((unsigned long *)&__m128i_result[0]) = 0x1e5f007f5d400000;
+ __m128i_out = __lsx_vavgr_d (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x000000000000ff00;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000800000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[1]) = 0x0000000400000000;
+ *((unsigned long *)&__m128i_result[0]) = 0x0000000000007f80;
+ __m128i_out = __lsx_vavgr_d (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.target/loongarch/vector/lsx/lsx-vavgr-2.c b/gcc/testsuite/gcc.target/loongarch/vector/lsx/lsx-vavgr-2.c
new file mode 100644
index 000000000..22908b1ea
--- /dev/null
+++ b/gcc/testsuite/gcc.target/loongarch/vector/lsx/lsx-vavgr-2.c
@@ -0,0 +1,317 @@
+/* { dg-do run } */
+/* { dg-options "-mlsx -w -fno-strict-aliasing" } */
+#include "../simd_correctness_check.h"
+#include <lsxintrin.h>
+
+int
+main ()
+{
+ __m128i __m128i_op0, __m128i_op1, __m128i_op2, __m128i_out, __m128i_result;
+ __m128 __m128_op0, __m128_op1, __m128_op2, __m128_out, __m128_result;
+ __m128d __m128d_op0, __m128d_op1, __m128d_op2, __m128d_out, __m128d_result;
+
+ int int_op0, int_op1, int_op2, int_out, int_result, i = 1, fail;
+ long int long_op0, long_op1, long_op2, lont_out, lont_result;
+ long int long_int_out, long_int_result;
+ unsigned int unsigned_int_out, unsigned_int_result;
+ unsigned long int unsigned_long_int_out, unsigned_long_int_result;
+
+ *((unsigned long *)&__m128i_op0[1]) = 0xfffffffff8f8dada;
+ *((unsigned long *)&__m128i_op0[0]) = 0xffffffff01018888;
+ *((unsigned long *)&__m128i_op1[1]) = 0xfffffffff8f8dada;
+ *((unsigned long *)&__m128i_op1[0]) = 0xffffffff01018888;
+ *((unsigned long *)&__m128i_result[1]) = 0xfffffffff8f8dada;
+ *((unsigned long *)&__m128i_result[0]) = 0xffffffff01018888;
+ __m128i_out = __lsx_vavgr_bu (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x7fffffffffffffff;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[0]) = 0x4080808080808080;
+ __m128i_out = __lsx_vavgr_bu (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x7fff7fff7fff7fff;
+ *((unsigned long *)&__m128i_op0[0]) = 0x000000010000003f;
+ *((unsigned long *)&__m128i_op1[1]) = 0x7fff7fff7fff7fff;
+ *((unsigned long *)&__m128i_op1[0]) = 0x000000010000003f;
+ *((unsigned long *)&__m128i_result[1]) = 0x7fff7fff7fff7fff;
+ *((unsigned long *)&__m128i_result[0]) = 0x000000010000003f;
+ __m128i_out = __lsx_vavgr_bu (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[0]) = 0x0000000000000000;
+ __m128i_out = __lsx_vavgr_bu (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000ffffffff0000;
+ *((unsigned long *)&__m128i_op0[0]) = 0xffffffffffffff00;
+ *((unsigned long *)&__m128i_op1[1]) = 0x1817161517161514;
+ *((unsigned long *)&__m128i_op1[0]) = 0x1615141315141312;
+ *((unsigned long *)&__m128i_result[1]) = 0x0c0c8b8a8b8b0b0a;
+ *((unsigned long *)&__m128i_result[0]) = 0x8b8a8a898a8a8909;
+ __m128i_out = __lsx_vavgr_bu (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x00003fff00003fff;
+ *((unsigned long *)&__m128i_op0[0]) = 0x00003fff00003fff;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[1]) = 0x0000208000002080;
+ *((unsigned long *)&__m128i_result[0]) = 0x0000208000002080;
+ __m128i_out = __lsx_vavgr_bu (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0xffffffffffd60015;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[0]) = 0x80808080806b000b;
+ __m128i_out = __lsx_vavgr_bu (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x7fff010181010102;
+ *((unsigned long *)&__m128i_op0[0]) = 0x7fffffff81010102;
+ *((unsigned long *)&__m128i_op1[1]) = 0x7fff010181010102;
+ *((unsigned long *)&__m128i_op1[0]) = 0x7fffffff81010102;
+ *((unsigned long *)&__m128i_result[1]) = 0x7fff010181010102;
+ *((unsigned long *)&__m128i_result[0]) = 0x7fffffff81010102;
+ __m128i_out = __lsx_vavgr_bu (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[0]) = 0x0000000000000000;
+ __m128i_out = __lsx_vavgr_bu (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[0]) = 0x0000000000000000;
+ __m128i_out = __lsx_vavgr_bu (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[0]) = 0x0000000000000000;
+ __m128i_out = __lsx_vavgr_hu (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0xffffffffffffffff;
+ *((unsigned long *)&__m128i_op0[0]) = 0xffffffffffffffff;
+ *((unsigned long *)&__m128i_op1[1]) = 0xc1bdceee242071db;
+ *((unsigned long *)&__m128i_op1[0]) = 0xe8c7b756d76aa578;
+ *((unsigned long *)&__m128i_result[1]) = 0xe0dee7779210b8ed;
+ *((unsigned long *)&__m128i_result[0]) = 0xf463dbabebb5d2bc;
+ __m128i_out = __lsx_vavgr_hu (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[0]) = 0x0000000000000000;
+ __m128i_out = __lsx_vavgr_hu (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[0]) = 0x0000000000000000;
+ __m128i_out = __lsx_vavgr_hu (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0xff80000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0xff80000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0xff80000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0xff80000000000000;
+ *((unsigned long *)&__m128i_result[1]) = 0xff80000000000000;
+ *((unsigned long *)&__m128i_result[0]) = 0xff80000000000000;
+ __m128i_out = __lsx_vavgr_hu (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[0]) = 0x0000000000000000;
+ __m128i_out = __lsx_vavgr_hu (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[0]) = 0x0000000000000000;
+ __m128i_out = __lsx_vavgr_hu (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000800000008;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x00007fff00007fff;
+ *((unsigned long *)&__m128i_op1[0]) = 0x000000002bfd9461;
+ *((unsigned long *)&__m128i_result[1]) = 0x0000400400004004;
+ *((unsigned long *)&__m128i_result[0]) = 0x0000000015ff4a31;
+ __m128i_out = __lsx_vavgr_hu (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x2a7b7c9260f90ee2;
+ *((unsigned long *)&__m128i_op1[0]) = 0x1b1c6cdfd57f5736;
+ *((unsigned long *)&__m128i_result[1]) = 0x153e3e49307d0771;
+ *((unsigned long *)&__m128i_result[0]) = 0x0d8e36706ac02b9b;
+ __m128i_out = __lsx_vavgr_hu (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0xdd6156076967d8c9;
+ *((unsigned long *)&__m128i_op0[0]) = 0x2e3ab5266375e71b;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000400000004;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000000400000004;
+ *((unsigned long *)&__m128i_result[1]) = 0x6eb12b0634b46c67;
+ *((unsigned long *)&__m128i_result[0]) = 0x171d5a9531bb7390;
+ __m128i_out = __lsx_vavgr_hu (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[0]) = 0x0000000000000000;
+ __m128i_out = __lsx_vavgr_hu (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000f50000000900;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000090900000998;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[1]) = 0x00007a8000000480;
+ *((unsigned long *)&__m128i_result[0]) = 0x00000485000004cc;
+ __m128i_out = __lsx_vavgr_hu (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x00003ff000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000fffc00000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000001;
+ *((unsigned long *)&__m128i_op1[0]) = 0xfffc001fffffffff;
+ *((unsigned long *)&__m128i_result[1]) = 0x00001ff800000001;
+ *((unsigned long *)&__m128i_result[0]) = 0x7ffe800e80000000;
+ __m128i_out = __lsx_vavgr_wu (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x00000000ffff53d9;
+ *((unsigned long *)&__m128i_op0[0]) = 0xff000001ffff9515;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000000000000001;
+ *((unsigned long *)&__m128i_result[1]) = 0x000000007fffa9ed;
+ *((unsigned long *)&__m128i_result[0]) = 0x7f8000017fffca8b;
+ __m128i_out = __lsx_vavgr_wu (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0xfffffffdfffffff8;
+ *((unsigned long *)&__m128i_result[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[0]) = 0x7fffffff7ffffffc;
+ __m128i_out = __lsx_vavgr_wu (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x00000001fffeff98;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0014ffe4ff76ffc4;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x3131313131313131;
+ *((unsigned long *)&__m128i_result[1]) = 0x000000017fff7fcc;
+ *((unsigned long *)&__m128i_result[0]) = 0x18a3188b9854187b;
+ __m128i_out = __lsx_vavgr_wu (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0xffff0000ffff0000;
+ *((unsigned long *)&__m128i_op0[0]) = 0xffff000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0xffff0000ffff0000;
+ *((unsigned long *)&__m128i_op1[0]) = 0xffff000000000000;
+ *((unsigned long *)&__m128i_result[1]) = 0xffff0000ffff0000;
+ *((unsigned long *)&__m128i_result[0]) = 0xffff000000000000;
+ __m128i_out = __lsx_vavgr_du (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000001c88bf0;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000000001c88bf0;
+ *((unsigned long *)&__m128i_result[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[0]) = 0x0000000001c88bf0;
+ __m128i_out = __lsx_vavgr_du (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0xffffffffffffffff;
+ *((unsigned long *)&__m128i_op0[0]) = 0x807fffff80800000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0006000000040000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0002000000000007;
+ *((unsigned long *)&__m128i_result[1]) = 0x8003000000020000;
+ *((unsigned long *)&__m128i_result[0]) = 0x4040ffffc0400004;
+ __m128i_out = __lsx_vavgr_du (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000010000010101;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0101000001000100;
+ *((unsigned long *)&__m128i_op1[1]) = 0xffffffffffffffff;
+ *((unsigned long *)&__m128i_op1[0]) = 0xffffffffffffffff;
+ *((unsigned long *)&__m128i_result[1]) = 0x8000008000008080;
+ *((unsigned long *)&__m128i_result[0]) = 0x8080800000800080;
+ __m128i_out = __lsx_vavgr_du (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[0]) = 0x0000000000000000;
+ __m128i_out = __lsx_vavgr_du (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[0]) = 0x0000000000000000;
+ __m128i_out = __lsx_vavgr_du (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ *((unsigned long *)&__m128i_op0[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op0[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_op1[0]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[1]) = 0x0000000000000000;
+ *((unsigned long *)&__m128i_result[0]) = 0x0000000000000000;
+ __m128i_out = __lsx_vavgr_du (__m128i_op0, __m128i_op1);
+ ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+ return 0;
+}
--
2.33.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/cenhuilin/gcc.git
[email protected]:cenhuilin/gcc.git
cenhuilin
gcc
gcc
master

搜索帮助