The problem with generating ~(boolean_var) for a 'not' pattern match is that, in the context of an if-statement, this results in if (~(boolean_var)). However, ~ promotes it to an integer. In case boolean_var is true, this operation thus results in a value of 111111[...]110, which evaluates to true, not false.
This isn't noticeable when the end result is immediately returned from a function as an i1 itself; but in cases where the end result is used in an if-statement it is incorrect.
By removing this pattern match, xor is just used for the code generation, which does work in this case.
The problem with generating
~(boolean_var)
for a 'not' pattern match is that, in the context of an if-statement, this results inif (~(boolean_var))
. However,~
promotes it to an integer. In caseboolean_var
is true, this operation thus results in a value of 111111[...]110, which evaluates to true, not false.This isn't noticeable when the end result is immediately returned from a function as an i1 itself; but in cases where the end result is used in an if-statement it is incorrect.
By removing this pattern match, xor is just used for the code generation, which does work in this case.