mirror of
https://github.com/ziglang/zig.git
synced 2026-02-03 13:13:40 +00:00
cbe: fix padding bits after a bitcast
This commit is contained in:
parent
085f6fd8f7
commit
f02b8a9cca
@ -3703,7 +3703,6 @@ fn airBitcast(f: *Function, inst: Air.Inst.Index) !CValue {
|
||||
const local = try f.allocLocal(inst_ty, .Const);
|
||||
try writer.writeAll(" = (");
|
||||
try f.renderTypecast(writer, inst_ty);
|
||||
|
||||
try writer.writeByte(')');
|
||||
try f.writeCValue(writer, operand, .Other);
|
||||
try writer.writeAll(";\n");
|
||||
@ -3721,6 +3720,17 @@ fn airBitcast(f: *Function, inst: Air.Inst.Index) !CValue {
|
||||
try f.renderTypecast(writer, inst_ty);
|
||||
try writer.writeAll("));\n");
|
||||
|
||||
// Ensure padding bits have the expected value.
|
||||
if (inst_ty.isAbiInt()) {
|
||||
try f.writeCValue(writer, local, .Other);
|
||||
try writer.writeAll(" = zig_wrap_");
|
||||
try f.object.dg.renderTypeForBuiltinFnName(writer, inst_ty);
|
||||
try writer.writeByte('(');
|
||||
try f.writeCValue(writer, local, .Other);
|
||||
try f.object.dg.renderBuiltinInfo(writer, inst_ty, .Bits);
|
||||
try writer.writeAll(");\n");
|
||||
}
|
||||
|
||||
return local;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user