From 632bbf2008d96b15bc20c5b7990b9544bc58086d Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Mon, 2 Jul 2018 22:38:29 -0700 Subject: [PATCH] Permit {s,u}{div,rem}_imm instructions to be potentially trapping. The documentation for these instructions suggests that immediate values which could lead to trapping should be invalid. While it seems nice to have these instructions be always non-trapping, it's also nice to say that the `_imm` forms of instructions are interchangeable with the corresponding non-`_imm` forms accompanied by `iconst` instructions. --- lib/codegen/meta/base/instructions.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/codegen/meta/base/instructions.py b/lib/codegen/meta/base/instructions.py index 1a490418d7..1d02b60cdc 100644 --- a/lib/codegen/meta/base/instructions.py +++ b/lib/codegen/meta/base/instructions.py @@ -1016,7 +1016,7 @@ udiv_imm = Instruction( 'udiv_imm', """ Unsigned integer division by an immediate constant. - This instruction never traps because a divisor of zero is not allowed. + This operation traps if the divisor is zero. """, ins=(x, Y), outs=a) @@ -1024,15 +1024,17 @@ sdiv_imm = Instruction( 'sdiv_imm', """ Signed integer division by an immediate constant. - This instruction never traps because a divisor of -1 or 0 is not - allowed. """, + This operation traps if the divisor is zero, or if the result is not + representable in :math:`B` bits two's complement. This only happens + when :math:`x = -2^{B-1}, Y = -1`. + """, ins=(x, Y), outs=a) urem_imm = Instruction( 'urem_imm', """ Unsigned integer remainder with immediate divisor. - This instruction never traps because a divisor of zero is not allowed. + This operation traps if the divisor is zero. """, ins=(x, Y), outs=a) @@ -1040,8 +1042,8 @@ srem_imm = Instruction( 'srem_imm', """ Signed integer remainder with immediate divisor. - This instruction never traps because a divisor of 0 or -1 is not - allowed. """, + This operation traps if the divisor is zero. + """, ins=(x, Y), outs=a) irsub_imm = Instruction(