[M3devel] volatile float/ter/copysign

Jay K jay.krell at cornell.edu
Sun Jul 4 17:50:03 CEST 2010


This is the code that often fails to compile.
Aha, well look at that.


PROCEDURE CopySign (x, y: T): T =
  VAR res := x;
  BEGIN
    LOOPHOLE (res, Rep.T).sign := LOOPHOLE (y, Rep.T).sign;
    RETURN res;
  END CopySign;


There's no loophole!
Store lreal, load int64->word8 => insert_mn => store int64->word8.
There are several other ways to write this code, but I guess that's not the point.


(552) begin_procedure
  procedure LongFloat__CopySign
 LongFloat__CopySign(553) set_source_line
  source line  117
(554) load
  type:lreal
  type:lreal
  m3cg_load (M3_CtKayy_x): offset 0x0, convert lreal -> lreal
(555) store
  type:lreal
  type:lreal
  store (M3_CtKayy_res) offset:0x0 src_t:lreal dst_t:lreal
(556) set_source_line
  source line  119
(557) load
  type:word8
  type:int64
  m3cg_load (M3_CtKayy_y): offset 0x38, convert word8 -> int64
(558) extract_mn
  type:int64
 extract_mn offset:7 count:1 sign_extend:0
(559) load
  type:word8
  type:int64
  m3cg_load (M3_CtKayy_res): offset 0x38, convert word8 -> int64
(560) swap
  type:int64
  type:int64
(561) insert_mn
  type:int64
 insert_mn offset:7 count:1
(562) store
  type:int64
  type:word8
  store (M3_CtKayy_res) offset:0x38 src_t:int64 dst_t:word8
(563) set_source_line
  source line  120
(564) load
  type:lreal
  type:lreal
  m3cg_load (M3_CtKayy_res): offset 0x0, convert lreal -> lreal
(565) exit_proc
  type:lreal
(566) end_procedure


 - Jay

 		 	   		  


More information about the M3devel mailing list