Closed undingen closed 4 years ago
I added a commit which fixes many more cases of garbage values/crashes when encountering comparisons with non int values
The example at the bottom produces comparisons with random values. With this change we produce the correct IR:
function u0:0(i64) -> i32 system_v {
ebb0(v0: i64):
v1 = iconst.i64 100
v2 = icmp eq v0, v1
v3 = bint.i32 v2
return v3
}
in the future we could specialcase llvm::ConstExpr
which produce a constant integer and directly merge it into the comparison to generate one less instruction.
But for now this enough to produce correct IR.
define dso_local i32 @foo(i8* readnone) {
%2 = icmp eq i8* %0, inttoptr (i64 100 to i8*)
%3 = zext i1 %2 to i32
ret i32 %3
}
Nice!
before this fix
either crashed or just inserted a random value (e.g 33 in my case):