Issue 114734
Summary [InstCombine] wrong folding of multiplication to shift for an undefined input
Labels new issue
Assignees
Reporter bongjunj
    https://github.com/llvm/llvm-project/blob/390300d9f41df6ad71f0f4196ef4885d4bd5dc48/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp#L1769-L1783

Alive2 report: https://alive2.llvm.org/ce/z/qqQmaw

```llvm
----------------------------------------
define i32 @ashr_mul_times_3_div_2_exact_2.2(i32 %x) {
#0:
  %#1 = sdiv i32 %x, 65535
  %mul = mul nsw i32 %#1, 3
  %ashr = ashr i32 %mul, 1
 ret i32 %ashr
}
=>
define i32 @ashr_mul_times_3_div_2_exact_2.2(i32 %x) {
#0:
  %#1 = sdiv i32 %x, 65535
  %#2 = ashr i32 %#1, 1
 %ashr = add nsw i32 %#1, %#2
  ret i32 %ashr
}
Transformation doesn't verify!

ERROR: Value mismatch

Example:
i32 %x = undef

Source:
i32 %#1 = #x00000000 (0)	[based on undef value]
i32 %mul = #x00000000 (0)
i32 %ashr = #x00000000 (0)

Target:
i32 %#1 = #x00000000 (0)
i32 %#2 = #x00000000 (0)
i32 %ashr = #x00000080 (128)
Source value: #x00000000 (0)
Target value: #x00000080 (128)

Summary:
  0 correct transformations
  1 incorrect transformations
  0 failed-to-prove transformations
  0 Alive2 errors
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to