Skip to content

VectorCombine transform leading to srem by poison #89390

@regehr

Description

@regehr

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

this:

define <4 x i32> @f(<4 x i32> %0, <4 x i32> %1) {
  %3 = srem <4 x i32> %1, %0
  %4 = srem <4 x i32> <i32 1, i32 1, i32 1, i32 1>, %0
  %5 = shufflevector <4 x i32> %3, <4 x i32> %4, <4 x i32> <i32 0, i32 poison, i32 6, i32 3>
  ret <4 x i32> %5
}

is getting vector-combined to this:

define <4 x i32> @f(<4 x i32> %0, <4 x i32> %1) {
  %3 = shufflevector <4 x i32> %1, <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32> <i32 0, i32 poison, i32 6, i32 3>
  %4 = shufflevector <4 x i32> %0, <4 x i32> poison, <4 x i32> <i32 0, i32 poison, i32 2, i32 3>
  %5 = srem <4 x i32> %3, %4
  ret <4 x i32> %5
}

but that poison in lane 1 is now problematic, this gives us full UB when it hits the srem

cc @nunoplopes @Hatsunespica

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions