Files
clang-p2996/llvm/test/CodeGen/NVPTX/boolean-patterns.ll
Alex MacLean 5e3ae4c4af [NVPTX] improve Boolean ISel (#80166)
Add TableGen patterns to convert more instructions to boolean
expressions:

- **mul -> and/or**: i1 multiply instructions currently cannot be
selected causing the compiler to crash. See
https://github.com/llvm/llvm-project/issues/57404
- **select -> and/or**: Converting selects to and/or can enable more
optimizations. `InstCombine` cannot do this as aggressively due to
poison semantics.
2024-01-31 14:37:27 -08:00

34 lines
789 B
LLVM

; RUN: llc < %s -march=nvptx64 -mcpu=sm_20 | FileCheck %s
; RUN: %if ptxas %{ llc < %s -march=nvptx64 -mcpu=sm_20 | %ptxas-verify %}
; CHECK-LABEL: m2and_rr
define i1 @m2and_rr(i1 %a, i1 %b) {
; CHECK: and.pred %p{{[0-9]+}}, %p{{[0-9]+}}, %p{{[0-9]+}}
; CHECK-NOT: mul
%r = mul i1 %a, %b
ret i1 %r
}
; CHECK-LABEL: m2and_ri
define i1 @m2and_ri(i1 %a) {
; CHECK-NOT: mul
%r = mul i1 %a, 1
ret i1 %r
}
; CHECK-LABEL: select2or
define i1 @select2or(i1 %a, i1 %b) {
; CHECK: or.b16 %rs{{[0-9]+}}, %rs{{[0-9]+}}, %rs{{[0-9]+}}
; CHECK-NOT: selp
%r = select i1 %a, i1 1, i1 %b
ret i1 %r
}
; CHECK-LABEL: select2and
define i1 @select2and(i1 %a, i1 %b) {
; CHECK: and.b16 %rs{{[0-9]+}}, %rs{{[0-9]+}}, %rs{{[0-9]+}}
; CHECK-NOT: selp
%r = select i1 %a, i1 %b, i1 0
ret i1 %r
}