https://bugs.llvm.org/show_bug.cgi?id=48343
Bug ID: 48343
Summary: [InstCombine] Miscompile of sext(ashr(shl(trunc())))
Product: libraries
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: Scalar Optimizations
Assignee: unassignedb...@nondot.org
Reporter: meh...@google.com
CC: llvm-bugs@lists.llvm.org
Example failing input:
define i10 @test(i10 %i) {
%a = trunc i10 %i to i3
%b = shl i3 %a, 2
%c = ashr i3 %b, 2
%d = sext i3 %c to i10
ret i10 %d
}
Bad code after optimizations:
$ opt -S --instcombine /tmp/fail.ll
; ModuleID = '/tmp/fail.ll'
source_filename = "/tmp/fail.ll"
define i10 @test(i10 %i) {
%d1 = shl i10 %i, 1
%d = ashr exact i10 %d1, 1
ret i10 %d
}
This should be shifting left by 9 then shifting right by 9, but (I think) the
optimization tries to create a 9 of type i3 which is the source of the bug:
https://github.com/llvm/llvm-project/blob/8cdf4920c47ddd3d60bdc3298f525512d483ce65/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp#L1526
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs