Skip to content

Commit

Permalink
rs6000: Use bcdsub. instead of bcdadd. for bcd invalid number checking
Browse files Browse the repository at this point in the history
bcdadd. might causes overflow which also set the overflow/invalid bit.
bcdsub. doesn't have the issue when do subtracting on two same bcd number.

gcc/
	* config/rs6000/altivec.md (*bcdinvalid_<mode>): Replace bcdadd
	with bcdsub.
	(bcdinvalid_<mode>): Likewise.

gcc/testsuite/
	* gcc.target/powerpc/bcd-4.c: Adjust the number of bcdadd and
	bcdsub.
  • Loading branch information
Haochen Gui committed Apr 25, 2024
1 parent d44c205 commit 09680e3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions gcc/config/rs6000/altivec.md
Original file line number Diff line number Diff line change
Expand Up @@ -4586,18 +4586,18 @@
[(set (reg:CCFP CR6_REGNO)
(compare:CCFP
(unspec:V2DF [(match_operand:VBCD 1 "register_operand" "v")]
UNSPEC_BCDADD)
UNSPEC_BCDSUB)
(match_operand:V2DF 2 "zero_constant" "j")))
(clobber (match_scratch:VBCD 0 "=v"))]
"TARGET_P8_VECTOR"
"bcdadd. %0,%1,%1,0"
"bcdsub. %0,%1,%1,0"
[(set_attr "type" "vecsimple")])

(define_expand "bcdinvalid_<mode>"
[(parallel [(set (reg:CCFP CR6_REGNO)
(compare:CCFP
(unspec:V2DF [(match_operand:VBCD 1 "register_operand")]
UNSPEC_BCDADD)
UNSPEC_BCDSUB)
(match_dup 2)))
(clobber (match_scratch:VBCD 3))])
(set (match_operand:SI 0 "register_operand")
Expand Down
4 changes: 2 additions & 2 deletions gcc/testsuite/gcc.target/powerpc/bcd-4.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
/* { dg-require-effective-target int128 } */
/* { dg-require-effective-target p9vector_hw } */
/* { dg-options "-mdejagnu-cpu=power9 -O2 -save-temps" } */
/* { dg-final { scan-assembler-times {\mbcdadd\M} 7 } } */
/* { dg-final { scan-assembler-times {\mbcdsub\M} 18 } } */
/* { dg-final { scan-assembler-times {\mbcdadd\M} 5 } } */
/* { dg-final { scan-assembler-times {\mbcdsub\M} 20 } } */
/* { dg-final { scan-assembler-times {\mbcds\M} 2 } } */
/* { dg-final { scan-assembler-times {\mdenbcdq\M} 1 } } */

Expand Down

0 comments on commit 09680e3

Please sign in to comment.