diff mbox

[committed] Fix PR target/52408 -- wrong code for left shift

Message ID 20120301194500.GA8959@hiauly1.hia.nrc.ca
State New
Headers show

Commit Message

John David Anglin March 1, 2012, 7:45 p.m. UTC
This patch fixes a target problem found with the Linux ext4 driver.

The zvdep_imm64 pattern truncated the 64-bit constant operand to 32-bits.
The truncated value was -1.  As a result, (x >> 4) + 1 was zero,
the call to exact_log2 failed, and thus the insert length for the constant
was wrong.  This is fixed by changing x to a unsigned HOST_WIDE_INT.

The other fixes are similar.

Tested on hppa2.0w-hp-hpux11.11 and hppa64-hp-hpux11.11.  Committed
to trunk.

Dave
diff mbox

Patch

Index: config/pa/pa.md
===================================================================
--- config/pa/pa.md	(revision 184661)
+++ config/pa/pa.md	(working copy)
@@ -6349,7 +6349,7 @@ 
   ""
   "*
 {
-  int x = INTVAL (operands[1]);
+  unsigned HOST_WIDE_INT x = UINTVAL (operands[1]);
   operands[2] = GEN_INT (4 + exact_log2 ((x >> 4) + 1));
   operands[1] = GEN_INT ((x & 0xf) - 0x10);
   return \"{zvdepi %1,%2,%0|depwi,z %1,%%sar,%2,%0}\";
@@ -6367,7 +6367,7 @@ 
   "exact_log2 (INTVAL (operands[1]) + 1) > 0"
   "*
 {
-  int x = INTVAL (operands[1]);
+  HOST_WIDE_INT x = INTVAL (operands[1]);
   operands[2] = GEN_INT (exact_log2 (x + 1));
   return \"{vdepi -1,%2,%0|depwi -1,%%sar,%2,%0}\";
 }"
@@ -6384,7 +6384,7 @@ 
   "INTVAL (operands[1]) == -2"
   "*
 {
-  int x = INTVAL (operands[1]);
+  HOST_WIDE_INT x = INTVAL (operands[1]);
   operands[2] = GEN_INT (exact_log2 ((~x) + 1));
   return \"{vdepi 0,%2,%0|depwi 0,%%sar,%2,%0}\";
 }"
@@ -6448,7 +6448,7 @@ 
   "TARGET_64BIT"
   "*
 {
-  int x = INTVAL (operands[1]);
+  unsigned HOST_WIDE_INT x = UINTVAL (operands[1]);
   operands[2] = GEN_INT (4 + exact_log2 ((x >> 4) + 1));
   operands[1] = GEN_INT ((x & 0x1f) - 0x20);
   return \"depdi,z %1,%%sar,%2,%0\";
@@ -6466,7 +6466,7 @@ 
   "TARGET_64BIT && exact_log2 (INTVAL (operands[1]) + 1) > 0"
   "*
 {
-  int x = INTVAL (operands[1]);
+  HOST_WIDE_INT x = INTVAL (operands[1]);
   operands[2] = GEN_INT (exact_log2 (x + 1));
   return \"depdi -1,%%sar,%2,%0\";
 }"
@@ -6483,7 +6483,7 @@ 
   "TARGET_64BIT && INTVAL (operands[1]) == -2"
   "*
 {
-  int x = INTVAL (operands[1]);
+  HOST_WIDE_INT x = INTVAL (operands[1]);
   operands[2] = GEN_INT (exact_log2 ((~x) + 1));
   return \"depdi 0,%%sar,%2,%0\";
 }"
Index: config/pa/predicates.md
===================================================================
--- config/pa/predicates.md	(revision 184661)
+++ config/pa/predicates.md	(working copy)
@@ -247,9 +247,9 @@ 
   (ior (match_operand 0 "ireg_operand")
        (match_operand 0 "int5_operand")))
 
-;; True iff OP is a CONST_INT of the forms 0...0xxxx or
-;; 0...01...1xxxx. Such values can be the left hand side x in (x <<
-;; r), using the zvdepi instruction.
+;; True iff OP is a CONST_INT of the forms 0...0xxxx, 0...01...1xxxx,
+;; or 1...1xxxx. Such values can be the left hand side x in (x << r),
+;; using the zvdepi instruction.
 
 (define_predicate "lhs_lshift_cint_operand"
   (match_code "const_int")