aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordrew <reserveblue@protonmail.com>2021-11-14 19:26:12 -0800
committerAndrew Kelley <andrew@ziglang.org>2021-11-16 16:51:31 -0700
commitdffa6dcaf93621ab8bbfdb8effad8bde6d73c20a (patch)
tree9cf00541b702a4bae58775bd2925ae05d6e6d811
parentad4627ea3b645e4dd51397fe4a2d92878c2bd9bf (diff)
downloadzig-dffa6dcaf93621ab8bbfdb8effad8bde6d73c20a.tar.gz
zig-dffa6dcaf93621ab8bbfdb8effad8bde6d73c20a.zip
make it more clear we should do UB wrapping optimizations for ptr arithmetic
-rw-r--r--src/codegen/c.zig5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/codegen/c.zig b/src/codegen/c.zig
index 554a60ad65..5fdc2b1c2a 100644
--- a/src/codegen/c.zig
+++ b/src/codegen/c.zig
@@ -1123,15 +1123,14 @@ fn genBody(f: *Function, body: []const Air.Inst.Index) error{ AnalysisFail, OutO
.unreach => try airUnreach(f),
.fence => try airFence(f, inst),
- .ptr_add => try airPtrAddSub (f, inst, " + "),
- .ptr_sub => try airPtrAddSub (f, inst, " - "),
-
// TODO use a different strategy for add that communicates to the optimizer
// that wrapping is UB.
.add => try airBinOp (f, inst, " + "),
+ .ptr_add => try airPtrAddSub (f, inst, " + "),
// TODO use a different strategy for sub that communicates to the optimizer
// that wrapping is UB.
.sub => try airBinOp (f, inst, " - "),
+ .ptr_sub => try airPtrAddSub (f, inst, " - "),
// TODO use a different strategy for mul that communicates to the optimizer
// that wrapping is UB.
.mul => try airBinOp (f, inst, " * "),