cbe: fix padding bits after a bitcast

This commit is contained in:
Jacob Young 2022-11-02 22:58:55 -04:00
parent 085f6fd8f7
commit f02b8a9cca

View File

@ -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;
}