Skip to content

Commit

Permalink
Generating an invert operation for boolean xor is invalid in most con…
Browse files Browse the repository at this point in the history
…texts due to integer promotion (#192)
  • Loading branch information
bcoppens committed Jan 16, 2024
1 parent 2f72e15 commit 0d5276c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
4 changes: 0 additions & 4 deletions lib/Target/CBackend/CBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4215,10 +4215,6 @@ void CWriter::visitBinaryOperator(BinaryOperator &I) {
Out << "-(";
writeOperand(X);
Out << ")";
} else if (match(&I, m_Not(m_Value(X)))) {
Out << "~(";
writeOperand(X);
Out << ")";
} else if (I.getOpcode() == Instruction::FRem) {
// Output a call to fmod/fmodf instead of emitting a%b
if (I.getType() == Type::getFloatTy(I.getContext()))
Expand Down
15 changes: 15 additions & 0 deletions test/ll_tests/test_if_bool_xor.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
define dso_local i1 @a() {
ret i1 1
}

define dso_local i32 @main() #0 {
%ret = call zeroext i1 @a()
%cond = xor i1 %ret, true
br i1 %cond, label %a_is_false, label %a_is_true

a_is_false:
ret i32 -1

a_is_true:
ret i32 6
}

0 comments on commit 0d5276c

Please sign in to comment.