Commit 3095f651 by Aaron Sawdey Committed by Aaron Sawdey

re PR target/79170 (memcmp builtin expansion sequence can overflow)

2017-01-27  Aaron Sawdey  <acsawdey@linux.vnet.ibm.com>

	PR target/79170
	* gcc.dg/memcmp-1.c: Improved to catch failures seen in PR 79170.

2017-01-27  Aaron Sawdey  <acsawdey@linux.vnet.ibm.com>

	PR target/79170
	* config/rs6000/altivec.md (*setb_internal): Rename to setb_signed.
	(setb_unsigned) New pattern for setb with CCUNS.
	* config/rs6000/rs6000.c (expand_block_compare): Use a different
	subfc./subfe sequence to avoid overflow problems.  Generate a
	shorter sequence with cmpld/setb for power9.
	* config/rs6000/rs6000.md (subf<mode>3_carry_dot2): Add a new pattern
	for generating subfc. instruction.
	(cmpstrsi): Add TARGET_POPCNTD predicate as the generate sequence
	now uses this instruction.

From-SVN: r245041
parent 8657c838
2017-01-30 Aaron Sawdey <acsawdey@linux.vnet.ibm.com>
PR target/79170
* config/rs6000/altivec.md (*setb_internal): Rename to setb_signed.
(setb_unsigned) New pattern for setb with CCUNS.
* config/rs6000/rs6000.c (expand_block_compare): Use a different
subfc./subfe sequence to avoid overflow problems. Generate a
shorter sequence with cmpld/setb for power9.
* config/rs6000/rs6000.md (subf<mode>3_carry_dot2): Add a new pattern
for generating subfc. instruction.
(cmpstrsi): Add TARGET_POPCNTD predicate as the generate sequence
now uses this instruction.
2017-01-30 Ian Lance Taylor <iant@google.com>
PR debug/79289
......
......@@ -3838,7 +3838,7 @@
;; Otherwise, set operand 0 to 0. Note that the result stored into
;; register operand 0 is non-zero iff either the LT or GT bits are on
;; within condition register operand 1.
(define_insn "*setb_internal"
(define_insn "setb_signed"
[(set (match_operand:SI 0 "gpc_reg_operand" "=r")
(if_then_else:SI (lt (match_operand:CC 1 "cc_reg_operand" "y")
(const_int 0))
......@@ -3851,6 +3851,19 @@
"setb %0,%1"
[(set_attr "type" "logical")])
(define_insn "setb_unsigned"
[(set (match_operand:SI 0 "gpc_reg_operand" "=r")
(if_then_else:SI (ltu (match_operand:CCUNS 1 "cc_reg_operand" "y")
(const_int 0))
(const_int -1)
(if_then_else (gtu (match_dup 1)
(const_int 0))
(const_int 1)
(const_int 0))))]
"TARGET_P9_MISC"
"setb %0,%1"
[(set_attr "type" "logical")])
;; Test byte within two ranges.
;;
;; The bytes of operand 1 are organized as xx:xx:xx:vv, where xx
......
......@@ -2068,6 +2068,35 @@
"subfic %0,%1,%2"
[(set_attr "type" "add")])
(define_insn_and_split "subf<mode>3_carry_dot2"
[(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
(compare:CC (minus:P (match_operand:P 2 "gpc_reg_operand" "r,r")
(match_operand:P 1 "gpc_reg_operand" "r,r"))
(const_int 0)))
(set (match_operand:P 0 "gpc_reg_operand" "=r,r")
(minus:P (match_dup 2)
(match_dup 1)))
(set (reg:P CA_REGNO)
(leu:P (match_dup 1)
(match_dup 2)))]
"<MODE>mode == Pmode"
"@
subfc. %0,%1,%2
#"
"&& reload_completed && cc_reg_not_cr0_operand (operands[3], CCmode)"
[(parallel [(set (match_dup 0)
(minus:P (match_dup 2)
(match_dup 1)))
(set (reg:P CA_REGNO)
(leu:P (match_dup 1)
(match_dup 2)))])
(set (match_dup 3)
(compare:CC (match_dup 0)
(const_int 0)))]
""
[(set_attr "type" "add")
(set_attr "dot" "yes")
(set_attr "length" "4,8")])
(define_insn "subf<mode>3_carry"
[(set (match_operand:P 0 "gpc_reg_operand" "=r")
......@@ -9146,11 +9175,11 @@
(match_operand:BLK 2)))
(use (match_operand:SI 3))
(use (match_operand:SI 4))])]
""
"TARGET_POPCNTD"
{
if (expand_block_compare (operands))
DONE;
else
else
FAIL;
})
......
2017-01-30 Aaron Sawdey <acsawdey@linux.vnet.ibm.com>
PR target/79170
* gcc.dg/memcmp-1.c: Improved to catch failures seen in PR 79170.
2017-01-30 Martin Sebor <msebor@redhat.com>
PR testsuite/79293
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment