ubsan: m32c: left shift of negative value
authorAlan Modra <amodra@gmail.com>
Mon, 3 Feb 2020 00:56:30 +0000 (11:26 +1030)
committerAlan Modra <amodra@gmail.com>
Mon, 3 Feb 2020 05:29:08 +0000 (15:59 +1030)
cpu/
* m32c.cpu (f-dsp-64-s16): Mask before shifting signed value.
opcodes/
* m32c-ibld.c: Regenerate.

cpu/ChangeLog
cpu/m32c.cpu
opcodes/ChangeLog
opcodes/m32c-ibld.c

index 5611cd19e2f73a16f392eef60c857bdf8d152d02..f67c869a86889cf01169f231f39606770b1b78b3 100644 (file)
@@ -1,3 +1,7 @@
+2020-02-03  Alan Modra  <amodra@gmail.com>
+
+       * m32c.cpu (f-dsp-64-s16): Mask before shifting signed value.
+
 2020-02-01  Alan Modra  <amodra@gmail.com>
 
        * frv.cpu (f-u12): Multiply rather than left shift signed values.
index 48b5acdfbd0ae166634bea03a2bc5dcb81826ff0..ab65fc13626731ce6d2a03fc0fbaf4ede1f1115e 100644 (file)
 (df f-dsp-64-s16 " 16 bit signed" (all-isas) 64 16 INT
      ((value pc) (ext INT 
                      (trunc HI
-                            (or (and (srl value 8) #x00ff)
-                                (and (sll value 8) #xff00))))) ; insert
+                            (or (and (srl value 8) #xff)
+                                (sll (and value #xff) 8))))) ; insert
      ((value pc) (ext INT 
                      (trunc HI
-                            (or (and (srl value 8) #x00ff)
-                                (and (sll value 8) #xff00))))) ; extract
+                            (or (and (srl value 8) #xff)
+                                (sll (and value #xff) 8))))) ; extract
 )
 
 ;-------------------------------------------------------------
index 6349ff07f76def0bfbe19fc0b83fa9848d015539..126025a312f8696a0b9eb89ce4df2a7410f48649 100644 (file)
@@ -1,3 +1,7 @@
+2020-02-03  Alan Modra  <amodra@gmail.com>
+
+       * m32c-ibld.c: Regenerate.
+
 2020-02-01  Alan Modra  <amodra@gmail.com>
 
        * frv-ibld.c: Regenerate.
index 7083a575e1a941c09744e9dfd51a85ffe1c229f4..36231f26dd960d83623f79823d4fbe4218b7917b 100644 (file)
@@ -1401,7 +1401,7 @@ m32c_cgen_insert_operand (CGEN_CPU_DESC cd,
     case M32C_OPERAND_IMM_64_HI :
       {
         long value = fields->f_dsp_64_s16;
-        value = EXTHISI (((HI) (INT) (((((((UINT) (value) >> (8))) & (255))) | (((((value) << (8))) & (65280)))))));
+        value = EXTHISI (((HI) (INT) (((((((UINT) (value) >> (8))) & (255))) | (((((value) & (255))) << (8)))))));
         errmsg = insert_normal (cd, value, 0|(1<<CGEN_IFLD_SIGNED), 64, 0, 16, 32, total_length, buffer);
       }
       break;
@@ -2561,7 +2561,7 @@ m32c_cgen_extract_operand (CGEN_CPU_DESC cd,
       {
         long value;
         length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 64, 0, 16, 32, total_length, pc, & value);
-        value = EXTHISI (((HI) (INT) (((((((UINT) (value) >> (8))) & (255))) | (((((value) << (8))) & (65280)))))));
+        value = EXTHISI (((HI) (INT) (((((((UINT) (value) >> (8))) & (255))) | (((((value) & (255))) << (8)))))));
         fields->f_dsp_64_s16 = value;
       }
       break;
This page took 0.03066 seconds and 4 git commands to generate.