From 22338bdfd0346e85a0e88ca5470302a4775e9054 Mon Sep 17 00:00:00 2001 From: Michael Forney Date: Thu, 14 Feb 2019 01:18:40 -0800 Subject: When subtracting pointers, divide after subtraction The pointers might be global addresses, and it doesn't make sense to divide them before subtracting. --- tests/subtract-pointer.qbe | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'tests/subtract-pointer.qbe') diff --git a/tests/subtract-pointer.qbe b/tests/subtract-pointer.qbe index 9e49d9c..0e7e9a3 100644 --- a/tests/subtract-pointer.qbe +++ b/tests/subtract-pointer.qbe @@ -8,10 +8,9 @@ function $f(l %.1, l %.3) { @body.2 %.5 =l loadl %.2 %.6 =l copy %.5 - %.7 =l udiv %.6, 4 - %.8 =l loadl %.4 - %.9 =l copy %.8 - %.10 =l udiv %.9, 4 - %.11 =l sub %.7, %.10 + %.7 =l loadl %.4 + %.8 =l copy %.7 + %.9 =l sub %.6, %.8 + %.10 =l div %.9, 4 ret } -- cgit v1.2.3