[Bug 295431] CURRENT compiler miscompiles lang/mit-scheme

From: <bugzilla-noreply_at_freebsd.org>
Date: Thu, 21 May 2026 13:31:21 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=295431

--- Comment #7 from John F. Carr <jfc@mit.edu> ---
The optimized IR has an instruction

  %add.ptr5.i = getelementptr inbounds nuw i8, ptr %.pre.i21, i64 -16

Commit ced15cd418d9 has a change

-      N = DAG.getNode(ISD::ADD, dl,
-                      N.getValueType(), N, IdxN);
+      // The successive addition of the current address, truncated to the
+      // pointer index type and interpreted as an unsigned number, and each
+      // offset, also interpreted as an unsigned number, does not wrap the
+      // pointer index type (add nuw).
+      SDNodeFlags AddFlags;
+      AddFlags.setNoUnsignedWrap(NW.hasNoUnsignedWrap());
+
+      N = DAG.getNode(ISD::ADD, dl, N.getValueType(), N, IdxN, AddFlags);

Commenting out the addition of no-unsigned-wrap fixes the problem.  The small
negative offset in the GEP will cause unsigned overflow if treated as a large
unsigned number.

I don't know whether the GEP is ill-formed, combining nuw with a negative
offset.

That's all for me for today.

-- 
You are receiving this mail because:
You are the assignee for the bug.