Commit dffa6dcaf9

drew <reserveblue@protonmail.com>
2021-11-15 04:26:12
make it more clear we should do UB wrapping optimizations for ptr arithmetic
1 parent ad4627e
Changed files (1)
src
codegen
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, " * "),