diff options
author | liuhongt <hongtao.liu@intel.com> | 2023-11-09 16:03:11 +0800 |
---|---|---|
committer | liuhongt <hongtao.liu@intel.com> | 2023-12-11 16:22:54 +0800 |
commit | 037f57025921e026d520c1eda26a54853e4cb245 (patch) | |
tree | 58f86819d69acc45d5b7c657947ce41c4f048e35 /gcc/c/c-tree.h | |
parent | 53e954a673a0d6ac80ab1f0591ea4f751e67374c (diff) | |
download | gcc-037f57025921e026d520c1eda26a54853e4cb245.zip gcc-037f57025921e026d520c1eda26a54853e4cb245.tar.gz gcc-037f57025921e026d520c1eda26a54853e4cb245.tar.bz2 |
Simplify vector ((VCE (a cmp b ? -1 : 0)) < 0) ? c : d to just (VCE ((a cmp b) ? (VCE c) : (VCE d))).
When I'm working on PR112443, I notice there's some misoptimizations:
after we fold _mm{,256}_blendv_epi8/pd/ps into gimple, the backend
fails to combine it back to v{,p}blendv{v,ps,pd} since the pattern is
too complicated, so I think maybe we should hanlde it in the gimple
level.
The dump is like
_1 = c_3(D) >= { 0, 0, 0, 0 };
_2 = VEC_COND_EXPR <_1, { -1, -1, -1, -1 }, { 0, 0, 0, 0 }>;
_7 = VIEW_CONVERT_EXPR<vector(32) char>(_2);
_8 = VIEW_CONVERT_EXPR<vector(32) char>(b_6(D));
_9 = VIEW_CONVERT_EXPR<vector(32) char>(a_5(D));
_10 = _7 < { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
_11 = VEC_COND_EXPR <_10, _8, _9>;
It can be optimized to
_1 = c_2(D) >= { 0, 0, 0, 0 };
_6 = VEC_COND_EXPR <_1, b_5(D), a_4(D)>;
since _7 is either -1 or 0, the selection of _7 < 0 ? _8 : _9 should
be euqal to _1 ? b : a as long as TYPE_PRECISION of the component type
of the second VEC_COND_EXPR is less equal to the first one.
The patch add a gimple pattern to handle that.
gcc/ChangeLog:
* match.pd (VCE (a cmp b ? -1 : 0) < 0) ? c : d ---> (VCE ((a
cmp b) ? (VCE:c) : (VCE:d))): New gimple simplication.
gcc/testsuite/ChangeLog:
* gcc.target/i386/avx512vl-blendv-3.c: New test.
* gcc.target/i386/blendv-3.c: New test.
Diffstat (limited to 'gcc/c/c-tree.h')
0 files changed, 0 insertions, 0 deletions