Skip to content

[InstCombine] sext(trunc(x)) should not be transformed to ashr(shl(trunc(x)))) when there is no chance to fold #116019

@wenju-he

Description

@wenju-he

Please check opt output in https://alive2.llvm.org/ce/z/faj-Rl
instcombine transforms

define void @src10(i64 %src1) {
entry:
  %1 = trunc i64 %src1 to i16
  %2 = sext i16 %1 to i32
  call void @use.i32(i32 %2)
  ret void
}

into

define void @tgt10(i64 %src1) {
entry:
  %1 = trunc i64 %src1 to i32
  %2 = shl i32 %1, 16
  %3 = ashr exact i32 %2, 16
  call void @use.i32(i32 %3)
  ret void
}

which should not be desired as the number of instructions increases.

Metadata

Metadata

Assignees

No one assigned

    Labels

    llvm:instcombineCovers the InstCombine, InstSimplify and AggressiveInstCombine passes

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions