mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 19:23:23 +01:00
8d9daddc1b
Even though we may not know the value of the shifter operand, it's possible we know the shifter operand is non-zero. This can allow us to infer more known bits - for example: %1 = load %p !range {1, 5} %2 = shl %q, %1 We don't know %1, but we do know that it is nonzero so %2[0] is known zero, and importantly %2 is known non-zero. Calling isKnownNonZero is nontrivially expensive so use an Optional to run it lazily and cache its result. llvm-svn: 251294
14 lines
365 B
LLVM
14 lines
365 B
LLVM
; RUN: opt -instsimplify -S < %s | FileCheck %s
|
|
|
|
; CHECK-LABEL: @test
|
|
define i1 @test(i8 %p, i8* %pq) {
|
|
%q = load i8, i8* %pq, !range !0 ; %q is known nonzero; no known bits
|
|
%1 = shl i8 %p, %q ; because %q is nonzero, %1[0] is known to be zero.
|
|
%2 = and i8 %1, 1
|
|
%x = icmp eq i8 %2, 0
|
|
; CHECK: ret i1 true
|
|
ret i1 %x
|
|
}
|
|
|
|
!0 = !{ i8 1, i8 5 }
|