[PATCH] Fix undefined behaviour in msp430 port

* config/msp430/msp430.c (msp430_legitimate_constant): Fix undefined
        left shift behaviour.
        * config/msp430/constraints.md ('L' constraint): Similarly.
        ('Ys' constraint): Similarly.

From-SVN: r228251
This commit is contained in:
Jeff Law 2015-09-29 10:25:21 -06:00 committed by Jeff Law
parent 6d60110654
commit 3ea7f8e524
3 changed files with 10 additions and 3 deletions

View File

@ -1,3 +1,10 @@
2015-09-29 Jeff Law <law@redhat.com>
* config/msp430/msp430.c (msp430_legitimate_constant): Fix undefined
left shift behaviour.
* config/msp430/constraints.md ('L' constraint): Similarly.
('Ys' constraint): Similarly.
2015-09-29 Richard Biener <rguenther@suse.de>
PR tree-optimization/67170

View File

@ -32,7 +32,7 @@
(define_constraint "L"
"Integer constant -1^20..1^19."
(and (match_code "const_int")
(match_test "IN_RANGE (ival, -1 << 20, 1 << 19)")))
(match_test "IN_RANGE (ival, HOST_WIDE_INT_M1U << 20, 1 << 19)")))
(define_constraint "M"
"Integer constant 1-4."
@ -77,7 +77,7 @@
(and (match_code "plus" "0")
(and (match_code "reg" "00")
(match_test ("CONST_INT_P (XEXP (XEXP (op, 0), 1))"))
(match_test ("IN_RANGE (INTVAL (XEXP (XEXP (op, 0), 1)), -1 << 15, (1 << 15)-1)"))))
(match_test ("IN_RANGE (INTVAL (XEXP (XEXP (op, 0), 1)), HOST_WIDE_INT_M1U << 15, (1 << 15)-1)"))))
(match_code "reg" "0")
)))

View File

@ -998,7 +998,7 @@ msp430_legitimate_constant (machine_mode mode, rtx x)
/* GCC does not know the width of the PSImode, so make
sure that it does not try to use a constant value that
is out of range. */
|| (INTVAL (x) < (1 << 20) && INTVAL (x) >= (-1 << 20));
|| (INTVAL (x) < (1 << 20) && INTVAL (x) >= (HOST_WIDE_INT)(HOST_WIDE_INT_M1U << 20));
}