llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

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

Open BreadTom opened this issue 6 months ago • 2 comments

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
}

BreadTom avatar May 30 '26 01:05 BreadTom

hey can you assign this issue to me ??

AnkitDubeycs25 avatar May 30 '26 05:05 AnkitDubeycs25

Closed by https://github.com/llvm/llvm-project/pull/200669

dtcxzyw avatar May 31 '26 23:05 dtcxzyw