https://sourceware.org/bugzilla/show_bug.cgi?id=19311

--- Comment #14 from Loria <Loria at phantasia dot org> ---
I did some further investigateion about the issue of the shiftoperator. It is
no violation on the syntaxlevel of C & C++ for (uint32 VAL; uint32 X = VAL >>
32;), the behaviour of the shiftoperation  >= bitsize of the value  is
undefinied.
At least Microsoft does state it in their documentation
https://msdn.microsoft.com/en-us/library/336xbhcz.aspx#Anchor_5
There are more places, which state the same.
So it seems the use of ">>32" confuses clangs optimizer.

But I now think the behaviour of the current version of 
encode_arm_immediate to be undefined and should be fixed. 

I sugest the code to be changed to:
<--
unsigned int
encode_arm_immediate (unsigned int val)
{
  unsigned int a, i;

  if(val <= 0xFF)
    return val;

  for (i = 2; i < 32 ; i += 2)
    if((a = rotate_left (val, i)) <= 0xFF)
      return a | (i << 7) ; /* 12-bit pack: [shift-cnt,const].  */
  return FAIL;
}
<--

shall I produce an patchfile ?

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils

Reply via email to