ubsan: m32c: left shift of negative value

Message ID 20200203052802.GM30118@bubble.grove.modra.org
State New
Headers show
Series
  • ubsan: m32c: left shift of negative value
Related show

Commit Message

Alan Modra Feb. 3, 2020, 5:28 a.m.
cpu/
	* m32c.cpu (f-dsp-64-s16): Mask before shifting signed value.
opcodes/
	* m32c-ibld.c: Regenerate.


-- 
Alan Modra
Australia Development Lab, IBM

Patch

diff --git a/cpu/m32c.cpu b/cpu/m32c.cpu
index 48b5acdfbd..ab65fc1362 100644
--- a/cpu/m32c.cpu
+++ b/cpu/m32c.cpu
@@ -781,12 +781,12 @@ 
 (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
 )
 
 ;-------------------------------------------------------------