public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Andrew Stubbs <ams@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-9299] vect: Fix integer overflow calculating mask Date: Mon, 4 Mar 2024 15:39:32 +0000 (GMT) [thread overview] Message-ID: <20240304153932.4B46E3858D28@sourceware.org> (raw) https://gcc.gnu.org/g:77eb86be8841989651b3150a020dd1a95910cc00 commit r14-9299-g77eb86be8841989651b3150a020dd1a95910cc00 Author: Andrew Stubbs <ams@baylibre.com> Date: Thu Feb 22 15:41:00 2024 +0000 vect: Fix integer overflow calculating mask The masks and bitvectors were broken when nunits==32 on hosts where int is 32-bit. gcc/ChangeLog: * dojump.cc (do_compare_and_jump): Use full-width integers for shifts. * expr.cc (store_constructor): Likewise. (do_store_flag): Likewise. Diff: --- gcc/dojump.cc | 4 ++-- gcc/expr.cc | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/gcc/dojump.cc b/gcc/dojump.cc index ac744e54cf8..88600cb42d3 100644 --- a/gcc/dojump.cc +++ b/gcc/dojump.cc @@ -1318,10 +1318,10 @@ do_compare_and_jump (tree treeop0, tree treeop1, enum rtx_code signed_code, { gcc_assert (code == EQ || code == NE); op0 = expand_binop (mode, and_optab, op0, - GEN_INT ((1 << nunits) - 1), NULL_RTX, + GEN_INT ((HOST_WIDE_INT_1U << nunits) - 1), NULL_RTX, true, OPTAB_WIDEN); op1 = expand_binop (mode, and_optab, op1, - GEN_INT ((1 << nunits) - 1), NULL_RTX, + GEN_INT ((HOST_WIDE_INT_1U << nunits) - 1), NULL_RTX, true, OPTAB_WIDEN); } diff --git a/gcc/expr.cc b/gcc/expr.cc index 8d34d024c9c..f7d74525c15 100644 --- a/gcc/expr.cc +++ b/gcc/expr.cc @@ -7879,8 +7879,8 @@ store_constructor (tree exp, rtx target, int cleared, poly_int64 size, auto nunits = TYPE_VECTOR_SUBPARTS (type).to_constant (); if (maybe_ne (GET_MODE_PRECISION (mode), nunits)) tmp = expand_binop (mode, and_optab, tmp, - GEN_INT ((1 << nunits) - 1), target, - true, OPTAB_WIDEN); + GEN_INT ((HOST_WIDE_INT_1U << nunits) - 1), + target, true, OPTAB_WIDEN); if (tmp != target) emit_move_insn (target, tmp); break; @@ -13707,11 +13707,11 @@ do_store_flag (sepops ops, rtx target, machine_mode mode) { gcc_assert (code == EQ || code == NE); op0 = expand_binop (mode, and_optab, op0, - GEN_INT ((1 << nunits) - 1), NULL_RTX, - true, OPTAB_WIDEN); + GEN_INT ((HOST_WIDE_INT_1U << nunits) - 1), + NULL_RTX, true, OPTAB_WIDEN); op1 = expand_binop (mode, and_optab, op1, - GEN_INT ((1 << nunits) - 1), NULL_RTX, - true, OPTAB_WIDEN); + GEN_INT ((HOST_WIDE_INT_1U << nunits) - 1), + NULL_RTX, true, OPTAB_WIDEN); } if (target == 0)
reply other threads:[~2024-03-04 15:39 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20240304153932.4B46E3858D28@sourceware.org \ --to=ams@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).