Jim Wilson <wilson at gcc dot> changed:

           What    |Removed                     |Added
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2018-03-03
                 CC|                            |wilson at gcc dot
     Ever confirmed|0                           |1

--- Comment #1 from Jim Wilson <wilson at gcc dot> ---
The shift count is either 0x2e or 0x2f depending on input.  It gets anded with
0xf, and used in an SImode shift, which shift-truncates, so the and is
optimized away as unnecessary.  The SImode shift later gets converted to a
DImode shift, and the code is wrong at that point, because shift by 0x2e/0x2f
gives different results in SImode and DImode.

The bad conversion happens in force_int_to_mode, case ASHIFT.  There is code to
check for shift counts outside the range of mode, however, it is comparing
against the target mode, which is the wider mode.  This code was added by

commit 129e53549ca138dbffd64aa11c5b94688010127b
Author: kenner <kenner@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Fri Apr 9 01:39:46 1993 +0000

    (force_to_mode, case xSHIFT): Don't narrow the mode unless we can be
    sure that the shift count is smaller than the size of the mode.

    git-svn-id: svn+ssh://

so this was clearly for the narrowing case.  We are missing a test for the
widening case, which is only necessary for targets that truncate shift counts.

Since the narrowing test is trivially true when widening, and the widening test
is trivially true when narrowing, I don't think we need to check for that, we
can just do both tests.

Reply via email to