combine: Punt on out of range rotate counts [PR93505]
commita73ee641c3d2ca729bdf55225afd881f57bf4d96
authorJakub Jelinek <jakub@redhat.com>
Fri, 14 Feb 2020 14:46:13 +0000 (14 15:46 +0100)
committerJakub Jelinek <jakub@redhat.com>
Fri, 14 Feb 2020 15:01:48 +0000 (14 16:01 +0100)
tree00f386ae78ad2e7494ec935c498684a1d6ef6f7f
parente0cbedff53ead3bbb6e7af959c727a04ec8445c7
combine: Punt on out of range rotate counts [PR93505]

What happens on this testcase is with the out of bounds rotate we get:
Trying 13 -> 16:
   13: r129:SI=r132:DI#0<-<0x20
      REG_DEAD r132:DI
   16: r123:DI=r129:SI<0
      REG_DEAD r129:SI
Successfully matched this instruction:
(set (reg/v:DI 123 [ <retval> ])
    (const_int 0 [0]))
during combine.  So, perhaps we could also change simplify-rtx.c to punt
if it is out of bounds rather than trying to optimize anything.
Or, but probably GCC11 material, if we decide that ROTATE/ROTATERT doesn't
have out of bounds counts or introduce targetm.rotate_truncation_mask,
we should truncate the argument instead of punting.
Punting is better for backports though.

2020-01-30  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/93505
* combine.c (simplify_comparison) <case ROTATE>: Punt on out of range
rotate counts.

* gcc.c-torture/compile/pr93505.c: New test.
gcc/ChangeLog
gcc/combine.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr93505.c [new file with mode: 0644]