ubsan: epiphany: left shift of negative value
authorAlan Modra <amodra@gmail.com>
Tue, 10 Dec 2019 07:36:09 +0000 (18:06 +1030)
committerAlan Modra <amodra@gmail.com>
Wed, 11 Dec 2019 01:04:33 +0000 (11:34 +1030)
Two places in epiphany_cgen_extract_operand, "value" is a long.
        value = ((((value) << (1))) + (pc));

cpu/
* epiphany.cpu (f-simm8, f-simm24): Use multiply rather than
shift left to avoid UB on left shift of negative values.
opcodes/
* epiphany-ibld.c: Regenerate.

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

index 87cec69e4f7c608b58dabe2a6ebe79c7b88a0378..fd26cb78b4b8256e8c07b49d32637e7be5ab9e9a 100644 (file)
@@ -1,3 +1,8 @@
+2019-12-11  Alan Modra  <amodra@gmail.com>
+
+       * epiphany.cpu (f-simm8, f-simm24): Use multiply rather than
+       shift left to avoid UB on left shift of negative values.
+
 2019-11-20  Jose E. Marchesi  <jose.marchesi@oracle.com>
 
        * bpf.cpu: Fix comment describing the 128-bit instruction format.
index 33c81d004f8a5d671c30d12ad62223547b959286..9f873b38f47bc254aaff6b73dc0cda86108546f0 100644 (file)
 
 (df f-simm8      "branch displacement"   (PCREL-ADDR RELOC) 15 8 INT
     ((value pc) (sra SI (sub SI value pc) 1))
-    ((value pc) (add SI (sll SI value 1) pc)))
+    ((value pc) (add SI (mul SI value 2) pc)))
 
 (df f-simm24     "branch displacement"   (PCREL-ADDR RELOC) 31 24 INT
     ((value pc) (sra SI (sub SI value pc) 1))
-    ((value pc) (add SI (sll SI value 1) pc)))
+    ((value pc) (add SI (mul SI value 2) pc)))
 
 (df f-sdisp3     "signed immediate 3 bit"      ()     9 3  INT #f #f)
 
index 4d22d51178626706f3d7c01701bc9fb932b15986..de76accd54238dcbb49b742f68273ba956af21f2 100644 (file)
@@ -1,3 +1,7 @@
+2019-12-11  Alan Modra  <amodra@gmail.com>
+
+       * epiphany-ibld.c: Regenerate.
+
 2019-12-10  Alan Modra  <amodra@gmail.com>
 
        PR 24960
index 83cfaf3fb8b94a6d0efc4d636b3467ac3ca952d9..6e6fd7be9714919e2af7daec2c83d6e38194941e 100644 (file)
@@ -1100,7 +1100,7 @@ epiphany_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_RELOC)|(1<<CGEN_IFLD_PCREL_ADDR), 0, 31, 24, 32, total_length, pc, & value);
-        value = ((((value) << (1))) + (pc));
+        value = ((((value) * (2))) + (pc));
         fields->f_simm24 = value;
       }
       break;
@@ -1111,7 +1111,7 @@ epiphany_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_RELOC)|(1<<CGEN_IFLD_PCREL_ADDR), 0, 15, 8, 32, total_length, pc, & value);
-        value = ((((value) << (1))) + (pc));
+        value = ((((value) * (2))) + (pc));
         fields->f_simm8 = value;
       }
       break;
This page took 0.028897 seconds and 4 git commands to generate.