1*7be5dabbSFujun Han; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2*7be5dabbSFujun Han; RUN: opt < %s -passes=instcombine -S | FileCheck %s 3*7be5dabbSFujun Han 4*7be5dabbSFujun Han; Pattern: 5*7be5dabbSFujun Han; (or (and (add x, half_c1), c3), (and x, c2)) 6*7be5dabbSFujun Han; IFF: 7*7be5dabbSFujun Han; c1, c2, c3 is constant 8*7be5dabbSFujun Han; c1 is pow2 9*7be5dabbSFujun Han; c2 < c1 10*7be5dabbSFujun Han; c3 == (c1 - 1) ^ c2 11*7be5dabbSFujun Han; half_c1 == (lshr c1, 1) 12*7be5dabbSFujun Han; (c1 >> 1) & c3 == (c1 >> 1) 13*7be5dabbSFujun Han; x is known to be less than c1 14*7be5dabbSFujun Han; Could be transformed into: 15*7be5dabbSFujun Han; (xor x, half_c1) 16*7be5dabbSFujun Han; The reason above transformation could be done is becase 17*7be5dabbSFujun Han; in (and (add x, half_c1), c3), half_c1 equals the top bit 18*7be5dabbSFujun Han; of the demanded mask indicated by (and ..., c3) 19*7be5dabbSFujun Han 20*7be5dabbSFujun Handefine i16 @or_and_add_and() { 21*7be5dabbSFujun Han; CHECK-LABEL: @or_and_add_and( 22*7be5dabbSFujun Han; CHECK-NEXT: entry: 23*7be5dabbSFujun Han; CHECK-NEXT: [[X:%.*]] = call i16 @dummy(), !range [[RNG0:![0-9]+]] 24*7be5dabbSFujun Han; CHECK-NEXT: [[OR:%.*]] = xor i16 [[X]], 32 25*7be5dabbSFujun Han; CHECK-NEXT: ret i16 [[OR]] 26*7be5dabbSFujun Han; 27*7be5dabbSFujun Hanentry: 28*7be5dabbSFujun Han %x = call i16 @dummy(), !range !0 29*7be5dabbSFujun Han %add = add i16 32, %x 30*7be5dabbSFujun Han %and1 = and i16 %add, 48 31*7be5dabbSFujun Han %and2 = and i16 %x, 15 32*7be5dabbSFujun Han %or = or i16 %and1, %and2 33*7be5dabbSFujun Han ret i16 %or 34*7be5dabbSFujun Han} 35*7be5dabbSFujun Han 36*7be5dabbSFujun Handeclare i16 @dummy() 37*7be5dabbSFujun Han 38*7be5dabbSFujun Han!0 = !{i16 0, i16 64} 39