Skip to content

[SLPVectorizer] nsw not dropped when negating int_min #206474

Description

@nikic

https://alive2.llvm.org/ce/z/wgB7Jz

; RUN: opt -passes=slp-vectorizer -slp-threshold=-1000 -mtriple=x86_64-unknown-linux-gnu < %s
define void @src(ptr %p, i32 %x, i32 %y) {
  %a = add nsw i32 %x, -2147483648
  %b = sub nsw i32 %y, 7
  store i32 %a, ptr %p, align 4
  %p1 = getelementptr inbounds i32, ptr %p, i64 1
  store i32 %b, ptr %p1, align 4
  ret void
}

define void @tgt(ptr %p, i32 %x, i32 %y) {
  %1 = insertelement <2 x i32> poison, i32 %x, i32 0
  %2 = insertelement <2 x i32> %1, i32 %y, i32 1
  %3 = sub nsw <2 x i32> %2, <i32 -2147483648, i32 7>
  store <2 x i32> %3, ptr %p, align 4
  ret void
}

When converting add to sub by negating the constant, we need to drop nsw if the constant is int_min.

Metadata

Metadata

Assignees

No one assigned

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions