Skip to content

[InstCombine] a & !a is not optimized #66606

Closed
@k-arrows

Description

@k-arrows

https://alive2.llvm.org/ce/z/e4RhjY

define i32 @src(i32 %0) {
%1:
  %2 = icmp eq i32 %0, 0
  %3 = zext i1 %2 to i32
  %4 = and i32 %3, %0
  ret i32 %4
}
=>
define i32 @tgt(i32 %0) {
%1:
  ret i32 0
}
Transformation seems to be correct!

Simple reproducer:
https://godbolt.org/z/YP7nEofeo

int foo (int a)
{
   return (a & !a);
}

FYI
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111431

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions