Index: llvm/test/Transforms/PhaseOrdering/reassociate-instcombine.ll =================================================================== --- /dev/null +++ llvm/test/Transforms/PhaseOrdering/reassociate-instcombine.ll @@ -0,0 +1,20 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py +; RUN: opt -O1 -S < %s | FileCheck %s + +; Make sure we reassociate and1 with and2 before instcombine to siplify +; (a & ~b) & ~c --> a & ~(b | c) +define i4 @not_reassociate_and_and_not(i4 %a, i4 %b, i4 %c, i4 %d) { +; CHECK-LABEL: @not_reassociate_and_and_not( +; CHECK-NEXT: [[TMP1:%.*]] = or i4 [[B:%.*]], [[C:%.*]] +; CHECK-NEXT: [[TMP2:%.*]] = xor i4 [[TMP1]], -1 +; CHECK-NEXT: [[AND2:%.*]] = and i4 [[TMP2]], [[A:%.*]] +; CHECK-NEXT: [[AND3:%.*]] = and i4 [[AND2]], [[D:%.*]] +; CHECK-NEXT: ret i4 [[AND3]] +; + %notb = xor i4 %b, -1 + %notc = xor i4 %c, -1 + %and1 = and i4 %a, %notb + %and2 = and i4 %and1, %d + %and3 = and i4 %and2, %notc + ret i4 %and3 +}