Files
revng-revng/tests/unit/llvm_lit_tests/TernaryReduction.ll
Alessandro Di Federico 0c212b66d9 Relicense to MIT
2024-02-29 17:03:36 +01:00

40 lines
1.3 KiB
LLVM

;
; This file is distributed under the MIT License. See LICENSE.md for details.
;
; RUN: %revngopt %s -ternary-reduction -S -o - | FileCheck %s
;
; Ensures that `ternary-reduction` did what was expected of it
define i1 @ternary_reduction_no_const (i1 %condition, i1 %if_true, i1 %if_false) {
; CHECK: %1 = select i1 %condition, i1 %if_true, i1 %if_false
%1 = select i1 %condition, i1 %if_true, i1 %if_false
ret i1 %1
}
define i1 @ternary_reduction_second_true (i1 %condition, i1 %if_true, i1 %if_false) {
; CHECK: %1 = or i1 %condition, %if_false
%1 = select i1 %condition, i1 true, i1 %if_false
ret i1 %1
}
define i1 @ternary_reduction_second_false (i1 %condition, i1 %if_true, i1 %if_false) {
; CHECK: %1 = call i1 @boolean_not(i1 %condition)
; CHECK-NEXT: %2 = and i1 %1, %if_false
%1 = select i1 %condition, i1 false, i1 %if_false
ret i1 %1
}
define i1 @ternary_reduction_third_true (i1 %condition, i1 %if_true, i1 %if_false) {
; CHECK: %1 = call i1 @boolean_not(i1 %condition)
; CHECK-NEXT: %2 = or i1 %1, %if_true
%1 = select i1 %condition, i1 %if_true, i1 true
ret i1 %1
}
define i1 @ternary_reduction_third_false (i1 %condition, i1 %if_true, i1 %if_false) {
; CHECK: %1 = and i1 %condition, %if_true
%1 = select i1 %condition, i1 %if_true, i1 false
ret i1 %1
}