Skip to content

[InstCombine] Miscompilation which simplifies a use of a multi-use freeze #91178

Closed

Description

Reduced test case: https://alive2.llvm.org/ce/z/_JyUGw

define i8 @func78(i1 %0, i8 %1) {
  %3 = zext i1 %0 to i8
  %4 = shl i8 %3, %1
  %5 = freeze i8 %4
  %6 = select i1 %0, i8 0, i8 %5
  %7 = call i8 @llvm.fshr.i8(i8 0, i8 %5, i8 %6)
  ret i8 %7
}
----------------------------------------
define i8 @func78(i1 %#0, i8 %#1) {
#2:
  %#3 = zext i1 %#0 to i8
  %#4 = shl i8 %#3, %#1
  %#5 = freeze i8 %#4
  %#6 = select i1 %#0, i8 0, i8 %#5
  %#7 = fshr i8 0, i8 %#5, i8 %#6
  ret i8 %#7
}
=>
define i8 @func78(i1 %#0, i8 %#1) nofree noundef willreturn memory(none) {
#2:
  %#3 = zext i1 %#0 to i8
  %#4 = shl nuw i8 %#3, %#1
  %#5 = freeze i8 %#4
  ret i8 %#5
}
Transformation doesn't verify!

ERROR: Value mismatch

Example:
i1 %#0 = #x0 (0)
i8 %#1 = #x08 (8)

Source:
i8 %#3 = #x00 (0)
i8 %#4 = poison
i8 %#5 = #x00 (0)
i8 %#6 = #x00 (0)
i8 %#7 = #x00 (0)

Target:
i8 %#3 = #x00 (0)
i8 %#4 = poison
i8 %#5 = #x9d (157, -99)
Source value: #x00 (0)
Target value: #x9d (157, -99)

Summary:
  0 correct transformations
  1 incorrect transformations
  0 failed-to-prove transformations
  0 Alive2 errors

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions