diff --git a/llvm/test/Transforms/InstCombine/fold-xor-and-select-i1.ll b/llvm/test/Transforms/InstCombine/fold-xor-and-select-i1.ll new file mode 100644 --- /dev/null +++ b/llvm/test/Transforms/InstCombine/fold-xor-and-select-i1.ll @@ -0,0 +1,16 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py +; RUN: opt < %s -passes=instcombine -S | FileCheck %s + +define i1 @max_if(i1 %a, i1 %b) { +; CHECK-LABEL: define i1 @max_if +; CHECK-SAME: (i1 [[A:%.*]], i1 [[B:%.*]]) { +; CHECK-NEXT: [[TMP1:%.*]] = xor i1 [[B]], true +; CHECK-NEXT: [[CMP:%.*]] = and i1 [[TMP1]], [[A]] +; CHECK-NEXT: [[TMP2:%.*]] = select i1 [[CMP]], i1 [[A]], i1 [[B]] +; CHECK-NEXT: ret i1 [[TMP2]] +; + %1 = xor i1 %b, true + %cmp = and i1 %1, %a + %2 = select i1 %cmp, i1 %a, i1 %b + ret i1 %2 +}