https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93127
Bug ID: 93127
Summary: PPC altivec vec_promote creates unnecessary xxpermdi
instruction
Product: gcc
Version: 8.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: jens.seifert at de dot ibm.com
Target Milestone: ---
vec_promote can leave half of register undefined and therefore should not issue
extra instruction.
Input:
#include <altivec.h>
double vmax(double a, double b)
{
#ifdef _BIG_ENDIAN
const int PREF = 0;
#else
const int PREF = 1;
#endif
vector double va = vec_promote(a,PREF);
vector double vb = vec_promote(b,PREF);
return vec_extract(vec_max(va, vb), PREF);
}
Output:
._Z4vmaxdd:
LFB..0:
xxpermdi 2,2,2,0
xxpermdi 1,1,1,0
xvmaxdp 1,1,2
# vec_extract to same register
blr
Both xxpermdi are unnecessary.