diff mbox series

[committed,nvptx] Emit mov.u32 instead of cvt.u32.u32 for truncsiqi2

Message ID 20201001192329.GA9331@delia
State New
Headers show
Series [committed,nvptx] Emit mov.u32 instead of cvt.u32.u32 for truncsiqi2 | expand

Commit Message

Tom de Vries Oct. 1, 2020, 7:23 p.m. UTC
Hi,

When running:
...
$ gcc.sh src/gcc/testsuite/gcc.target/nvptx/abi-complex-arg.c -S -dP
...
we have in abi-complex-arg.s:
...
//(insn 3 5 4 2
//  (set
//    (reg:QI 23)
//    (truncate:QI (reg:SI 22))) "abi-complex-arg.c":38:1 29 {truncsiqi2}
//  (nil))
                cvt.u32.u32     %r23, %r22;     // 3    [c=4]  truncsiqi2/0
...

The cvt.u32.u32 can be written shorter and clearer as mov.u32.

Fix this in define_insn "truncsi<QHIM>2".

Tested on nvptx.

Committed to trunk.

Thanks,
- Tom

[nvptx] Emit mov.u32 instead of cvt.u32.u32 for truncsiqi2

gcc/ChangeLog:

2020-10-01  Tom de Vries  <tdevries@suse.de>

	PR target/80845
	* config/nvptx/nvptx.md (define_insn "truncsi<QHIM>2"): Emit mov.u32
	instead of cvt.u32.u32.

---
 gcc/config/nvptx/nvptx.md | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/gcc/config/nvptx/nvptx.md b/gcc/config/nvptx/nvptx.md
index 035f6e0151b..ccbcd096fd1 100644
--- a/gcc/config/nvptx/nvptx.md
+++ b/gcc/config/nvptx/nvptx.md
@@ -383,9 +383,13 @@  (define_insn "truncsi<mode>2"
   [(set (match_operand:QHIM 0 "nvptx_nonimmediate_operand" "=R,m")
 	(truncate:QHIM (match_operand:SI 1 "nvptx_register_operand" "R,R")))]
   ""
-  "@
-   %.\\tcvt%t0.u32\\t%0, %1;
-   %.\\tst%A0.u%T0\\t%0, %1;"
+  {
+    if (which_alternative == 1)
+      return "%.\\tst%A0.u%T0\\t%0, %1;";
+    if (GET_MODE (operands[0]) == QImode)
+      return "%.\\tmov%t0\\t%0, %1;";
+    return "%.\\tcvt%t0.u32\\t%0, %1;";
+  }
   [(set_attr "subregs_ok" "true")])
 
 (define_insn "truncdi<mode>2"