Skip to content

Missed Optimization: fold disjoint bitwise ORs (with select/zext i1) into a single constant select #163108

@Leo0506

Description

@Leo0506
define i8 @src(i1 %arg0) {
  %v0 = zext i1 %arg0 to i8
  %v1 = select i1 %arg0, i8 0, i8 8
  %v2 = or disjoint i8 %v1, %v0
  %v3 = or disjoint i8 %v2, 16
  ret i8 %v3
}

define i8 @tgt(i1 %arg0) {
  %v1 = select i1 %arg0, i8 17, i8 24
  ret i8 %v1
}

alive2: https://alive2.llvm.org/ce/z/vSQli0
godbolt: https://godbolt.org/z/543Mvx7MG
Pattern Found in: https://github.com/dtcxzyw/llvm-opt-benchmark/blob/main/bench/llvm/optimized/CGExpr.ll

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions