From: Guozhi Wei Date: Wed, 27 Aug 2014 16:48:09 +0000 (+0000) Subject: re PR target/62262 (aarch64 gcc generates invalid assembler) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3d0b75dee41113c397caabd6b5690c6c39204d0d;p=gcc.git re PR target/62262 (aarch64 gcc generates invalid assembler) PR target/62262 * config/aarch64/aarch64.md (*andim_ashift_bfiz): Check the shift amount before using it. * gcc.target/aarch64/pr62262.c: New test. From-SVN: r214578 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 6ccb0d32e9d..66eece0e809 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2014-08-27 Guozhi Wei + + PR target/62262 + * config/aarch64/aarch64.md (*andim_ashift_bfiz): Check the shift + amount before using it. + 2014-08-27 Richard Biener * gimple-fold.c (get_maxval_strlen): Add overload wrapping diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md index 3c51fd367e9..1f7ab9151ba 100644 --- a/gcc/config/aarch64/aarch64.md +++ b/gcc/config/aarch64/aarch64.md @@ -3431,7 +3431,8 @@ (and:GPI (ashift:GPI (match_operand:GPI 1 "register_operand" "r") (match_operand 2 "const_int_operand" "n")) (match_operand 3 "const_int_operand" "n")))] - "exact_log2 ((INTVAL (operands[3]) >> INTVAL (operands[2])) + 1) >= 0 + "(INTVAL (operands[2]) < ()) + && exact_log2 ((INTVAL (operands[3]) >> INTVAL (operands[2])) + 1) >= 0 && (INTVAL (operands[3]) & ((1 << INTVAL (operands[2])) - 1)) == 0" "ubfiz\\t%0, %1, %2, %P3" [(set_attr "type" "bfm")] diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3290e7da34e..883582291b4 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-08-27 Guozhi Wei + + PR target/62262 + * gcc.target/aarch64/pr62262.c: New test. + 2014-08-26 Joseph Myers PR target/60606 diff --git a/gcc/testsuite/gcc.target/aarch64/pr62262.c b/gcc/testsuite/gcc.target/aarch64/pr62262.c new file mode 100644 index 00000000000..5bf90bf7fe3 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/pr62262.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fprofile-use" } */ + +static inline int CLZ(int mask) { + return mask ? __builtin_clz(mask) : 32; +} + +int foo(int value) +{ + if (value == 0) + return 0; + + int bias = CLZ(value); + value >>= bias; + int zeros = CLZ(value << 1); + value <<= zeros; + + int packed = (unsigned)(value << 9) >> 9; + return packed; +}