Skip to content

Comparison of add of extended booleans not folded to xor #64859

Closed
@arsenm

Description

@arsenm

I was looking at some code that tried to compute a sort of enum scheme by adding booleans, and comparing to constant values which failed to form nice boolean code. This is really just an xor.

https://alive2.llvm.org/ce/z/RSnV-d

define i1 @src(i1 %arg, i1 %arg1) {
bb:
  %i = zext i1 %arg to i32
  %i2 = zext i1 %arg1 to i32
  %i3 = add nuw nsw i32 %i2, %i
  %i4 = icmp eq i32 %i3, 1
  ret i1 %i4
}

define i1 @tgt(i1 %arg, i1 %arg1) {
bb:
  %xor = xor i1 %arg, %arg1
  ret i1 %xor
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions