tests: exercise wide 32-bit products and unsigned umul16
Add runtime markers for a full-width 32x32 multiply (0x12345678 * 0x9abcdef0 = 0x242d2080) and for a wide-dividend remainder, so a 16-bit-truncated MPYS or a wrong FS1 cannot still produce the expected small results. Compute the 16x16 unsigned product in unsigned arithmetic to remove the signed-overflow annotation, and reject a regressed nuw nsw multiply in the optimized IR.
This commit is contained in:
1 parent
7cd9a48ee3
commit
00522b56fc
3 files changed
+29
-10
No files matched your search
+10
-1
@@ -34,6 +34,15 @@ if grep -Eq '\bmul i(33|64)\b' "$WORK/asm/loop.ll"; then
|
||||
fi
|
||||
echo " ok driver -O2 loop IR has no i33/i64 multiply"
|
||||
|
||||
# The 16x16 unsigned product must not carry the old signed-overflow
|
||||
# annotation. With the multiply done in unsigned arithmetic the IR is
|
||||
# `mul nuw`, not `mul nuw nsw`; the latter contradicts the 0xfffe0001 result.
|
||||
if awk '/^define .*@umul16\(/{infn=1} infn{print} infn && /^}/{exit}' \
|
||||
"$WORK/asm/mul.ll" | grep -q 'mul nuw nsw'; then
|
||||
fail "umul16 still has a signed no-wrap multiply (the product is unsigned)"
|
||||
fi
|
||||
echo " ok umul16 multiplies without signed no-wrap"
|
||||
|
||||
# Stop at the next function label (a column-0 label that is not an LBB block
|
||||
# label), so a following local function cannot leak into this slice.
|
||||
body() { # body FILE FUNC
|
||||
@@ -49,7 +58,7 @@ body() { # body FILE FUNC
|
||||
TMP=$(mktemp -d "${TMPDIR:-/tmp}/m4-mul.XXXXXX")
|
||||
trap 'rm -rf "$TMP"' EXIT HUP INT TERM
|
||||
|
||||
EXPECTED="M4: mul=42 umul16=4294836225 sdiv=14 udiv=613566756 srem=2 urem=2 sdivneg=4294967282 sremneg=4294967294 sumto=55 squares=30"
|
||||
EXPECTED="M4: mul=42 umul16=4294836225 sdiv=14 udiv=613566756 srem=2 urem=2 sdivneg=4294967282 sremneg=4294967294 sumto=55 squares=30 widemul=606937216 widerem=2"
|
||||
grep -Fqx "$EXPECTED" "$WORK/mame.log" \
|
||||
|| { grep -E '^M4: ' "$WORK/mame.log" >&2 || true; fail "runtime markers did not match: $EXPECTED"; }
|
||||
echo " ok runtime markers: $EXPECTED"
|
||||
|
||||
Reference in new issue
Block a user