Skip to content

[missed-optimization] 1 >> x to x == 0 #200538

@BreadTom

Description

@BreadTom

GCC r15-6929 optimizes 1 >> x to x == 0

LLVM trunk miss this optimization this pattern with -O3:

LLVM IR:

define i32 @src(i32 %a) {
entry:
  %shr = lshr i32 1, %a
  ret i32 %shr
}

define i32 @tgt(i32 %a) {
entry:
  %cmp = icmp eq i32 %a, 0
  %conv = zext i1 %cmp to i32
  ret i32 %conv
}

Metadata

Metadata

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions