brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.3 KiB · 2292abd Raw
119 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py2; Test for (x & y) + ~(x | y) -> ~(x ^ y)3; RUN: opt < %s -passes=instcombine -S | FileCheck %s4 5; (x & y) + ~(x | y)6define i32 @src(i32 noundef %0, i32 noundef %1) {7; CHECK-LABEL: @src(8; CHECK-NEXT:    [[TMP3:%.*]] = xor i32 [[TMP1:%.*]], [[TMP0:%.*]]9; CHECK-NEXT:    [[TMP4:%.*]] = xor i32 [[TMP3]], -110; CHECK-NEXT:    ret i32 [[TMP4]]11;12  %3 = and i32 %1, %013  %4 = or i32 %1, %014  %5 = xor i32 %4, -115  %6 = add i32 %3, %516  ret i32 %617}18 19; vector version of src20define <2 x i32> @src_vec(<2 x i32> noundef %0, <2 x i32> noundef %1) {21; CHECK-LABEL: @src_vec(22; CHECK-NEXT:    [[TMP3:%.*]] = xor <2 x i32> [[TMP1:%.*]], [[TMP0:%.*]]23; CHECK-NEXT:    [[TMP4:%.*]] = xor <2 x i32> [[TMP3]], splat (i32 -1)24; CHECK-NEXT:    ret <2 x i32> [[TMP4]]25;26  %3 = and <2 x i32> %1, %027  %4 = or  <2 x i32> %1, %028  %5 = xor <2 x i32> %4, <i32 -1, i32 -1>29  %6 = add <2 x i32> %3, %530  ret <2 x i32> %631}32 33; vector version of src with poison values34define <2 x i32> @src_vec_poison(<2 x i32> noundef %0, <2 x i32> noundef %1) {35; CHECK-LABEL: @src_vec_poison(36; CHECK-NEXT:    [[TMP3:%.*]] = xor <2 x i32> [[TMP1:%.*]], [[TMP0:%.*]]37; CHECK-NEXT:    [[TMP4:%.*]] = xor <2 x i32> [[TMP3]], splat (i32 -1)38; CHECK-NEXT:    ret <2 x i32> [[TMP4]]39;40  %3 = and <2 x i32> %1, %041  %4 = or  <2 x i32> %1, %042  %5 = xor <2 x i32> %4, <i32 -1, i32 poison>43  %6 = add <2 x i32> %3, %544  ret <2 x i32> %645}46 47; (x & y) + ~(y | x)48define i32 @src2(i32 noundef %0, i32 noundef %1) {49; CHECK-LABEL: @src2(50; CHECK-NEXT:    [[TMP3:%.*]] = xor i32 [[TMP1:%.*]], [[TMP0:%.*]]51; CHECK-NEXT:    [[TMP4:%.*]] = xor i32 [[TMP3]], -152; CHECK-NEXT:    ret i32 [[TMP4]]53;54  %3 = and i32 %1, %055  %4 = or i32 %0, %156  %5 = xor i32 %4, -157  %6 = add i32 %3, %558  ret i32 %659}60 61; (x & y) + (~x & ~y)62define i32 @src3(i32 noundef %0, i32 noundef %1) {63; CHECK-LABEL: @src3(64; CHECK-NEXT:    [[TMP3:%.*]] = xor i32 [[TMP1:%.*]], [[TMP0:%.*]]65; CHECK-NEXT:    [[TMP4:%.*]] = xor i32 [[TMP3]], -166; CHECK-NEXT:    ret i32 [[TMP4]]67;68  %3 = and i32 %1, %069  %4 = xor i32 %0, -170  %5 = xor i32 %1, -171  %6 = and i32 %4, %572  %7 = add i32 %3, %673  ret i32 %774}75 76; ~(x | y) + (y & x)77define i32 @src4(i32 noundef %0, i32 noundef %1) {78; CHECK-LABEL: @src4(79; CHECK-NEXT:    [[TMP3:%.*]] = xor i32 [[TMP0:%.*]], [[TMP1:%.*]]80; CHECK-NEXT:    [[TMP4:%.*]] = xor i32 [[TMP3]], -181; CHECK-NEXT:    ret i32 [[TMP4]]82;83  %3 = and i32 %0, %184  %4 = or i32 %1, %085  %5 = xor i32 %4, -186  %6 = add i32 %3, %587  ret i32 %688}89 90; ~(x | y) + (x & y)91define i32 @src5(i32 noundef %0, i32 noundef %1) {92; CHECK-LABEL: @src5(93; CHECK-NEXT:    [[TMP3:%.*]] = xor i32 [[TMP1:%.*]], [[TMP0:%.*]]94; CHECK-NEXT:    [[TMP4:%.*]] = xor i32 [[TMP3]], -195; CHECK-NEXT:    ret i32 [[TMP4]]96;97  %3 = or i32 %1, %098  %4 = xor i32 %3, -199  %5 = and i32 %1, %0100  %6 = add i32 %4, %5101  ret i32 %6102}103 104; (a & b) + ~(c | d)105define i32 @src6(i32 %0, i32 %1, i32 %2, i32 %3) {106; CHECK-LABEL: @src6(107; CHECK-NEXT:    [[TMP5:%.*]] = and i32 [[TMP0:%.*]], [[TMP1:%.*]]108; CHECK-NEXT:    [[TMP6:%.*]] = or i32 [[TMP2:%.*]], [[TMP3:%.*]]109; CHECK-NEXT:    [[TMP7:%.*]] = xor i32 [[TMP6]], -1110; CHECK-NEXT:    [[TMP8:%.*]] = add i32 [[TMP5]], [[TMP7]]111; CHECK-NEXT:    ret i32 [[TMP8]]112;113  %5 = and i32 %0, %1114  %6 = or i32 %2, %3115  %7 = xor i32 %6, -1116  %8 = add i32 %5, %7117  ret i32 %8118}119