llvm-project
llvm-project copied to clipboard
[InstCombine] alive reported incorrect transformation on `--debug-counter=instcombine-visit=2`
alive: https://alive2.llvm.org/ce/z/u_Qehj
Reproducer
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
declare i32 @llvm.fshl.i32(i32, i32, i32)
define i8 @f(i1 %c) {
entry:
%x = select i1 %c, i32 -2147483520, i32 -2147483392
%r = call i32 @llvm.fshl.i32(i32 %x, i32 %x, i32 1), !range !0
%t = trunc i32 %r to i8
%f = freeze i8 %t
ret i8 %f
}
!0 = !{i32 257, i32 514}
=>
; ModuleID = './repro.ll'
source_filename = "./repro.ll"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
; Function Attrs: nocallback nocreateundeforpoison nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.fshl.i32(i32, i32, i32) #0
define i8 @f(i1 %c) {
entry:
%x = select i1 %c, i32 -2147483520, i32 -2147483392
%r = call i32 @llvm.fshl.i32(i32 -2147483648, i32 %x, i32 1), !range !0
%t = trunc i32 %r to i8
%f = freeze i8 %t
ret i8 %f
}
attributes #0 = { nocallback nocreateundeforpoison nofree nosync nounwind speculatable willreturn memory(none) }
!0 = !{i32 257, i32 514}
$ alive-tv repro.ll --passes='instcombine' --debug-counter=instcombine-visit=2
...
Transformation doesn't verify!
ERROR: Value mismatch
Example:
i1 %c = #x0 (0)
Reproduced on local build of e85a62955715c5ff38b685303379313ac81a0bbf. However, on godbolt (https://godbolt.org/z/Kn7MdEv8h), the range metadata does not exist in optimized, and alive reported that the transformation is correct for godbolt-produced optimized IR. Maybe it's a false positive from alive, but I'm not sure, so open the issue for this.
I found that the filter on Godbolt blocks the reproduction; Here are the godbolt and src-tgt alive reproduction links: godbolt: https://godbolt.org/z/nj6aYYfsc alive: https://alive2.llvm.org/ce/z/Lk8Eop
Hi, I'd like to take this issue!