Skip to content

[InstCombine] Regard zext nneg as sext when folding add(zext neg(add)) #88348

Closed
@dianqk

Description

@dianqk

The following transformation is legal after adding nneg:

define i32 @src(i8 %v) {
  %switch.tableidx = add nsw i8 %v, 1
  %switch.idx.cast = zext nneg i8 %switch.tableidx to i32
  %switch.offset = add nsw i32 %switch.idx.cast, -1
  ret i32 %switch.offset
}

define i32 @tgt(i8 %v) {
  %ext = sext i8 %v to i32
  ret i32 %ext
}

Alive2: https://alive2.llvm.org/ce/z/2iCmDs
From: rust-lang/rust#106459 (comment)

Metadata

Metadata

Assignees

Labels

good first issuehttps://github.com/llvm/llvm-project/contributellvm:instcombineCovers the InstCombine, InstSimplify and AggressiveInstCombine passesmissed-optimization

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions