aboutsummaryrefslogtreecommitdiff
path: root/gcc/hsa-gen.c
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2016-02-22 15:14:51 +0100
committerMartin Liska <marxin@gcc.gnu.org>2016-02-22 14:14:51 +0000
commitf91d04e77d33e9f09758b6e5cb69a7d5555a3e39 (patch)
tree1d2d1f5ec203cf55ce55834f79bf5d62393d0aab /gcc/hsa-gen.c
parentf88d45dc171e59e120817912115550b943c30b22 (diff)
downloadgcc-f91d04e77d33e9f09758b6e5cb69a7d5555a3e39.zip
gcc-f91d04e77d33e9f09758b6e5cb69a7d5555a3e39.tar.gz
gcc-f91d04e77d33e9f09758b6e5cb69a7d5555a3e39.tar.bz2
HSA: fix emission of clrsb{l,ll} builtins
* hsa-gen.c (gen_hsa_clrsb): In case of zero value, return bitsize - 1 as the return value. From-SVN: r233602
Diffstat (limited to 'gcc/hsa-gen.c')
-rw-r--r--gcc/hsa-gen.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/gcc/hsa-gen.c b/gcc/hsa-gen.c
index 768c2cf..28e8b6f 100644
--- a/gcc/hsa-gen.c
+++ b/gcc/hsa-gen.c
@@ -4055,7 +4055,9 @@ gen_hsa_clrsb (gcall *call, hsa_bb *hbb)
hsa_op_with_type *arg = hsa_reg_or_immed_for_gimple_op (rhs1, hbb);
BrigType16_t bittype = hsa_bittype_for_type (arg->m_type);
unsigned bitsize = tree_to_uhwi (TYPE_SIZE (TREE_TYPE (rhs1)));
- gcc_checking_assert (bitsize >= 32);
+
+ /* FIRSTBIT instruction is defined just for 32 and 64-bits wide integers. */
+ gcc_checking_assert (bitsize == 32 || bitsize == 64);
/* Set true to MOST_SIG if the most significant bit is set to one. */
hsa_op_immed *c = new hsa_op_immed (1ul << (bitsize - 1),
@@ -4098,9 +4100,10 @@ gen_hsa_clrsb (gcall *call, hsa_bb *hbb)
new hsa_op_immed (0, arg->m_type));
hbb->append_insn (cmp);
- /* Return the number of leading bits, or 31 if the input value is zero. */
+ /* Return the number of leading bits,
+ or (bitsize - 1) if the input value is zero. */
cmov = new hsa_insn_basic (4, BRIG_OPCODE_CMOV, BRIG_TYPE_B32, NULL, is_zero,
- new hsa_op_immed (31, BRIG_TYPE_U32),
+ new hsa_op_immed (bitsize - 1, BRIG_TYPE_U32),
leading_bits->get_in_type (BRIG_TYPE_B32, hbb));
hbb->append_insn (cmov);
cmov->set_output_in_type (dest, 0, hbb);