fix divide by zero bugs
authorYunsup Lee <yunsup@cs.berkeley.edu>
Mon, 30 Jan 2012 22:38:23 +0000 (14:38 -0800)
committerYunsup Lee <yunsup@cs.berkeley.edu>
Mon, 30 Jan 2012 22:38:23 +0000 (14:38 -0800)
riscv/insns/divuw.h
riscv/insns/divw.h
riscv/insns/remuw.h
riscv/insns/remw.h

index 0ceb04025a017e6d8ea8ae723919d9f37cb3a6d0..2cf051141ca8ffa35ae1f18f5b9b80c482719982 100644 (file)
@@ -1,5 +1,5 @@
 require_xpr64;
-if(RS2 == 0)
+if(zext32(RS2) == 0)
   RD = UINT64_MAX;
 else
   RD = sext32(zext32(RS1) / zext32(RS2));
index 51c3d8042f29d2361babd5d5db497f6b41657144..84f42a9b3094345e22ad4367e35c2266db826862 100644 (file)
@@ -1,5 +1,5 @@
 require_xpr64;
-if(RS2 == 0)
+if(int32_t(RS2) == 0)
   RD = UINT64_MAX;
 else if(int32_t(RS1) == INT32_MIN && int32_t(RS2) == -1)
   RD = RS1;
index 8234af382726a3ae1523de563637902e586d212f..1cc015ded15d67ebd9b983a4f78f01bd5634f5df 100644 (file)
@@ -1,5 +1,5 @@
 require_xpr64;
-if(RS2 == 0)
+if(zext_xprlen(RS2) == 0)
   RD = RS1;
 else
   RD = sext32(zext_xprlen(RS1) % zext_xprlen(RS2));
index 93c38588efb48cbd0411030e7c1ac93a5b2f2dd2..1093533e3f2d9e62e568c7ee331792501c01553b 100644 (file)
@@ -1,5 +1,5 @@
 require_xpr64;
-if(RS2 == 0)
+if(int32_t(RS2) == 0)
   RD = RS1;
 else if(int32_t(RS1) == INT32_MIN && int32_t(RS2) == -1)
   RD = 0;