diff options
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index a2e9632..5e34863 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -1388,7 +1388,11 @@ const_binop (enum tree_code code, tree arg1, tree arg2) if (shiftc >= outerc || (shiftc % innerc) != 0) return NULL_TREE; int offset = shiftc / innerc; - if (code == VEC_LSHIFT_EXPR) + /* The direction of VEC_[LR]SHIFT_EXPR is endian dependent. + For reductions, compiler emits VEC_RSHIFT_EXPR always, + for !BYTES_BIG_ENDIAN picks first vector element, but + for BYTES_BIG_ENDIAN last element from the vector. */ + if ((code == VEC_RSHIFT_EXPR) ^ (!BYTES_BIG_ENDIAN)) offset = -offset; tree zero = build_zero_cst (TREE_TYPE (type)); for (i = 0; i < count; i++) |