]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Committed] Restore build on !TARGET_TRULY_NOOP_TRUNCATION targets
authorRoger Sayle <roger@nextmovesoftware.com>
Mon, 23 Aug 2021 14:35:05 +0000 (15:35 +0100)
committerRoger Sayle <roger@nextmovesoftware.com>
Mon, 23 Aug 2021 14:35:05 +0000 (15:35 +0100)
My sincere apologies to everyone, but especially Andrew Pinski
who warned me in advance that TRULY_NOOP_TRUNCATION results in
different code paths/optimizations on some targets. This restores
the build on nvptx-none (and presumably others) where mysteriously
(truncate:QI (reg:QI)) fails to be simplified to (reg:QI), which
is expected (everywhere) in my recently added self-tests.

2021-08-23  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
* simplify-rtx.c (simplify_unary_operation_1): [TRUNCATE]:
Handle case where the operand is already the desired mode.

gcc/simplify-rtx.c

index f3df6140766febcf423aaef351a0e6db198f4d58..8eea9fb7e0a61b079b60652e28297b4cf3f6a216 100644 (file)
@@ -1268,6 +1268,9 @@ simplify_context::simplify_unary_operation_1 (rtx_code code, machine_mode mode,
            return temp;
        }
 
+      /* Check for useless truncation.  */
+      if (GET_MODE (op) == mode)
+       return op;
       break;
 
     case FLOAT_TRUNCATE: