Skip to content

[InstCombine] a && (a | b) is not simplified #69038

Open
@k-arrows

Description

@k-arrows

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

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

Reproducer:
https://godbolt.org/z/YEqW7sE6n

int foo(int a, int b)
{
   return a && (a | b);
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions