diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2018-09-17 18:13:38 -0400 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2018-09-17 18:13:38 -0400 |
| commit | cf9200b81594071d6378df2294da1c737c780c05 (patch) | |
| tree | 2ad8766ea3e088fb2bc6fba6792b49ce7239d217 /src/ir.cpp | |
| parent | 4c6f1e614a204293732004ef844e8bb057bdc212 (diff) | |
| download | zig-cf9200b81594071d6378df2294da1c737c780c05.tar.gz zig-cf9200b81594071d6378df2294da1c737c780c05.zip | |
dereferencing a *u0 is comptime-known to be 0
Diffstat (limited to 'src/ir.cpp')
| -rw-r--r-- | src/ir.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/ir.cpp b/src/ir.cpp index ce044aa0f3..f4b727412e 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -11187,6 +11187,13 @@ static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruc } } } + // dereferencing a *u0 is comptime known to be 0 + if (child_type->id == ZigTypeIdInt && child_type->data.integral.bit_count == 0) { + IrInstruction *result = ir_create_const(&ira->new_irb, source_instruction->scope, + source_instruction->source_node, child_type); + init_const_unsigned_negative(&result->value, child_type, 0, false); + return result; + } // TODO if the instruction is a const ref instruction we can skip it IrInstruction *load_ptr_instruction = ir_build_load_ptr(&ira->new_irb, source_instruction->scope, source_instruction->source_node, ptr); |
