ubsan: frv: left shift of negative value
authorAlan Modra <amodra@gmail.com>
Sat, 1 Feb 2020 02:38:43 +0000 (13:08 +1030)
committerAlan Modra <amodra@gmail.com>
Sat, 1 Feb 2020 12:53:18 +0000 (23:23 +1030)
More non-bugs flagged by ubsan, unless you happen to be compiling for
a 1's complement host.

cpu/
* frv.cpu (f-u12): Multiply rather than left shift signed values.
(f-label16, f-label24): Likewise.
opcodes/
* frv-ibld.c: Regenerate.

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

index 3e8f019e353eab91735db1884f25dbb8cce15e85..5611cd19e2f73a16f392eef60c857bdf8d152d02 100644 (file)
@@ -1,3 +1,8 @@
+2020-02-01  Alan Modra  <amodra@gmail.com>
+
+       * frv.cpu (f-u12): Multiply rather than left shift signed values.
+       (f-label16, f-label24): Likewise.
+
 2020-01-30  Alan Modra  <amodra@gmail.com>
 
        * m32c.cpu (f-src32-rn-unprefixed-QI): Shift before inverting.
index b6c4f809bd6eabf2e4f4481d30249423714ee1d6..cdb169eddc1c11d99df72a32e14f86e6d07de391 100644 (file)
                (set (ifield f-u12-l) (and (ifield f-u12) #x3f))
                )
       (sequence () ; extract
-               (set (ifield f-u12) (or (sll (ifield f-u12-h) 6)
+               (set (ifield f-u12) (or (mul (ifield f-u12-h) 64)
                                        (ifield f-u12-l)))
                )
 )
 
 (df  f-label16    "18 bit pc relative signed offset" (PCREL-ADDR) 15 16 INT
      ((value pc) (sra WI (sub WI value pc) (const 2)))
-     ((value pc) (add WI (sll WI value (const 2)) pc))
+     ((value pc) (add WI (mul WI value (const 4)) pc))
 )
 
 (df   f-labelH6   "upper 6  bits of label24"  () 30  6 INT #f #f)
       ; extract
       (sequence ()
                (set (ifield f-label24)
-                    (add (sll (or (sll (ifield f-labelH6) (const 18))
+                    (add (mul (or (mul (ifield f-labelH6) (sll 1 18))
                                   (ifield f-labelL18))
-                              (const 2))
+                              (const 4))
                          pc)))
 )
 
index f163ad2f3ec1bb33fc27d0283c6ce198e4611f88..6349ff07f76def0bfbe19fc0b83fa9848d015539 100644 (file)
@@ -1,3 +1,7 @@
+2020-02-01  Alan Modra  <amodra@gmail.com>
+
+       * frv-ibld.c: Regenerate.
+
 2020-01-31  Jan Beulich  <jbeulich@suse.com>
 
        * i386-dis.c (EXxmm_mdq, xmm_mdq_mode): Delete.
index 34396f53737c7bd711e40db5981c424490aac1fb..5e31df272ee4b1cb962003cce93cd6c7b8f7e981 100644 (file)
@@ -1090,7 +1090,7 @@ frv_cgen_extract_operand (CGEN_CPU_DESC cd,
       {
         long value;
         length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED)|(1<<CGEN_IFLD_PCREL_ADDR), 0, 15, 16, 32, total_length, pc, & value);
-        value = ((((value) << (2))) + (pc));
+        value = ((((value) * (4))) + (pc));
         fields->f_label16 = value;
       }
       break;
@@ -1101,7 +1101,7 @@ frv_cgen_extract_operand (CGEN_CPU_DESC cd,
         length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 18, 32, total_length, pc, & fields->f_labelL18);
         if (length <= 0) break;
 {
-  FLD (f_label24) = ((((((((FLD (f_labelH6)) << (18))) | (FLD (f_labelL18)))) << (2))) + (pc));
+  FLD (f_label24) = ((((((((FLD (f_labelH6)) * (((1) << (18))))) | (FLD (f_labelL18)))) * (4))) + (pc));
 }
       }
       break;
@@ -1156,7 +1156,7 @@ frv_cgen_extract_operand (CGEN_CPU_DESC cd,
         length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 6, 32, total_length, pc, & fields->f_u12_l);
         if (length <= 0) break;
 {
-  FLD (f_u12) = ((((FLD (f_u12_h)) << (6))) | (FLD (f_u12_l)));
+  FLD (f_u12) = ((((FLD (f_u12_h)) * (64))) | (FLD (f_u12_l)));
 }
       }
       break;
This page took 0.030751 seconds and 4 git commands to generate.