diff mbox

[ARM] Fix CLZ_DEFINED_VALUE_AT_ZERO for vector modes

Message ID 543633BD.9030004@linaro.org
State New
Headers show

Commit Message

Michael Collison Oct. 9, 2014, 7:05 a.m. UTC
The CLZ_DEFINED_VALUE_AT_ZERO macro is harded to return 32. For the 
vector intrinsic vclz this is incorrect and should return the value 
eight. The CTZ_DEFINED_VALUE_AT_ZERO has the same issue.

Tested on arm-linux-gnueabihf, arm-linux-gnueabi.

2014-10-08  Michael Collison  <michael.collison@linaro.com>

     * config/arm/arm.h (CLZ_DEFINED_VALUE_AT_ZERO) : Update
     to support vector modes
     (CTZ_DEFINED_VALUE_AT_ZERO): Ditto

Comments

Andrew Pinski Oct. 9, 2014, 7:11 a.m. UTC | #1
On Thu, Oct 9, 2014 at 12:05 AM, Michael Collison
<michael.collison@linaro.org> wrote:
>
> The CLZ_DEFINED_VALUE_AT_ZERO macro is harded to return 32. For the vector
> intrinsic vclz this is incorrect and should return the value eight. The
> CTZ_DEFINED_VALUE_AT_ZERO has the same issue.


Do you have a testcase?  I almost think you should have a testcase
which causes the constant folding.  Though I don't think there is
constant folding of the vector clz/ctz happening.

Thanks,
Andrew

>
> Tested on arm-linux-gnueabihf, arm-linux-gnueabi.
>
> 2014-10-08  Michael Collison  <michael.collison@linaro.com>
>
>     * config/arm/arm.h (CLZ_DEFINED_VALUE_AT_ZERO) : Update
>     to support vector modes
>     (CTZ_DEFINED_VALUE_AT_ZERO): Ditto
>
> --
> Michael Collison
> Linaro Toolchain Working Group
> michael.collison@linaro.org
>
Michael Collison Oct. 9, 2014, 7:26 a.m. UTC | #2
Yes this problem was found with Christophe's neon intrinsic tests which 
are awaiting approval. The problem was found by passing a value of zero 
to the vclz vector intrinsic.

On 10/09/2014 12:11 AM, Andrew Pinski wrote:
> On Thu, Oct 9, 2014 at 12:05 AM, Michael Collison
> <michael.collison@linaro.org> wrote:
>> The CLZ_DEFINED_VALUE_AT_ZERO macro is harded to return 32. For the vector
>> intrinsic vclz this is incorrect and should return the value eight. The
>> CTZ_DEFINED_VALUE_AT_ZERO has the same issue.
>
> Do you have a testcase?  I almost think you should have a testcase
> which causes the constant folding.  Though I don't think there is
> constant folding of the vector clz/ctz happening.
>
> Thanks,
> Andrew
>
>> Tested on arm-linux-gnueabihf, arm-linux-gnueabi.
>>
>> 2014-10-08  Michael Collison  <michael.collison@linaro.com>
>>
>>      * config/arm/arm.h (CLZ_DEFINED_VALUE_AT_ZERO) : Update
>>      to support vector modes
>>      (CTZ_DEFINED_VALUE_AT_ZERO): Ditto
>>
>> --
>> Michael Collison
>> Linaro Toolchain Working Group
>> michael.collison@linaro.org
>>
Tejas Belagod Oct. 9, 2014, 7:55 a.m. UTC | #3
On 09/10/14 08:05, Michael Collison wrote:
>
> The CLZ_DEFINED_VALUE_AT_ZERO macro is harded to return 32. For the
> vector intrinsic vclz this is incorrect and should return the value
> eight. The CTZ_DEFINED_VALUE_AT_ZERO has the same issue.
>
> Tested on arm-linux-gnueabihf, arm-linux-gnueabi.
>
> 2014-10-08  Michael Collison  <michael.collison@linaro.com>
>
>       * config/arm/arm.h (CLZ_DEFINED_VALUE_AT_ZERO) : Update
>       to support vector modes
>       (CTZ_DEFINED_VALUE_AT_ZERO): Ditto
>

Update comment?

/* The arm5 clz instruction returns 32.  */


Thanks,
Tejas.
Michael Collison Oct. 9, 2014, 7:56 a.m. UTC | #4
Tejas,

You are correct. I will update the comment.

On 10/9/2014 12:55 AM, Tejas Belagod wrote:
> On 09/10/14 08:05, Michael Collison wrote:
>>
>> The CLZ_DEFINED_VALUE_AT_ZERO macro is harded to return 32. For the
>> vector intrinsic vclz this is incorrect and should return the value
>> eight. The CTZ_DEFINED_VALUE_AT_ZERO has the same issue.
>>
>> Tested on arm-linux-gnueabihf, arm-linux-gnueabi.
>>
>> 2014-10-08  Michael Collison <michael.collison@linaro.com>
>>
>>       * config/arm/arm.h (CLZ_DEFINED_VALUE_AT_ZERO) : Update
>>       to support vector modes
>>       (CTZ_DEFINED_VALUE_AT_ZERO): Ditto
>>
>
> Update comment?
>
> /* The arm5 clz instruction returns 32.  */
>
>
> Thanks,
> Tejas.
>
diff mbox

Patch

--- ../../../../linaro-gcc4_9_git/gcc/config/arm/arm.h	2014-10-08 13:49:01.109819957 -0700
+++ arm.h	2014-10-08 13:56:19.509841175 -0700
@@ -2138,8 +2138,10 @@  extern int making_const_table;
    : reverse_condition (code))
 
 /* The arm5 clz instruction returns 32.  */
-#define CLZ_DEFINED_VALUE_AT_ZERO(MODE, VALUE)  ((VALUE) = 32, 1)
-#define CTZ_DEFINED_VALUE_AT_ZERO(MODE, VALUE)  ((VALUE) = 32, 1)
+#define CLZ_DEFINED_VALUE_AT_ZERO(MODE, VALUE) \
+  ((VALUE) = GET_MODE_UNIT_BITSIZE (MODE))
+#define CTZ_DEFINED_VALUE_AT_ZERO(MODE, VALUE) \
+  ((VALUE) = GET_MODE_UNIT_BITSIZE (MODE))
 
 #define CC_STATUS_INIT \
   do { cfun->machine->thumb1_cc_insn = NULL_RTX; } while (0)