113 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py2; RUN: opt < %s -passes=instcombine -S | FileCheck %s3 4declare i8 @gen8()5declare void @use8(i8)6 7@a = global i8 178 9define i8 @t0_scalar(i8 %x, i8 %y) {10; CHECK-LABEL: @t0_scalar(11; CHECK-NEXT: [[TMP1:%.*]] = xor i8 [[X:%.*]], [[Y:%.*]]12; CHECK-NEXT: [[R:%.*]] = xor i8 [[TMP1]], 4213; CHECK-NEXT: ret i8 [[R]]14;15 %i0 = xor i8 %x, 4216 %r = xor i8 %i0, %y17 ret i8 %r18}19 20define <2 x i8> @t1_splatvec(<2 x i8> %x, <2 x i8> %y) {21; CHECK-LABEL: @t1_splatvec(22; CHECK-NEXT: [[TMP1:%.*]] = xor <2 x i8> [[X:%.*]], [[Y:%.*]]23; CHECK-NEXT: [[R:%.*]] = xor <2 x i8> [[TMP1]], splat (i8 42)24; CHECK-NEXT: ret <2 x i8> [[R]]25;26 %i0 = xor <2 x i8> %x, <i8 42, i8 42>27 %r = xor <2 x i8> %i0, %y28 ret <2 x i8> %r29}30define <2 x i8> @t2_vec(<2 x i8> %x, <2 x i8> %y) {31; CHECK-LABEL: @t2_vec(32; CHECK-NEXT: [[TMP1:%.*]] = xor <2 x i8> [[X:%.*]], [[Y:%.*]]33; CHECK-NEXT: [[R:%.*]] = xor <2 x i8> [[TMP1]], <i8 42, i8 24>34; CHECK-NEXT: ret <2 x i8> [[R]]35;36 %i0 = xor <2 x i8> %x, <i8 42, i8 24>37 %r = xor <2 x i8> %i0, %y38 ret <2 x i8> %r39}40define <2 x i8> @t3_vec_undef(<2 x i8> %x, <2 x i8> %y) {41; CHECK-LABEL: @t3_vec_undef(42; CHECK-NEXT: [[TMP1:%.*]] = xor <2 x i8> [[X:%.*]], [[Y:%.*]]43; CHECK-NEXT: [[R:%.*]] = xor <2 x i8> [[TMP1]], <i8 42, i8 undef>44; CHECK-NEXT: ret <2 x i8> [[R]]45;46 %i0 = xor <2 x i8> %x, <i8 42, i8 undef>47 %r = xor <2 x i8> %i0, %y48 ret <2 x i8> %r49}50 51define i8 @t4_extrause(i8 %x, i8 %y) {52; CHECK-LABEL: @t4_extrause(53; CHECK-NEXT: [[I0:%.*]] = xor i8 [[X:%.*]], 4254; CHECK-NEXT: call void @use8(i8 [[I0]])55; CHECK-NEXT: [[R:%.*]] = xor i8 [[I0]], [[Y:%.*]]56; CHECK-NEXT: ret i8 [[R]]57;58 %i0 = xor i8 %x, 4259 call void @use8(i8 %i0)60 %r = xor i8 %i0, %y61 ret i8 %r62}63 64define i8 @t5_commutativity(i8 %x) {65; CHECK-LABEL: @t5_commutativity(66; CHECK-NEXT: [[Y:%.*]] = call i8 @gen8()67; CHECK-NEXT: [[TMP1:%.*]] = xor i8 [[X:%.*]], [[Y]]68; CHECK-NEXT: [[R:%.*]] = xor i8 [[TMP1]], 4269; CHECK-NEXT: ret i8 [[R]]70;71 %i0 = xor i8 %x, 4272 %y = call i8 @gen8()73 %r = xor i8 %y, %i074 ret i8 %r75}76 77@global_constant = internal global i32 0, align 478@global_constant2 = internal global i32 0, align 479 80define i8 @constantexpr(i8 %or) local_unnamed_addr #0 {81; CHECK-LABEL: @constantexpr(82; CHECK-NEXT: entry:83; CHECK-NEXT: [[R:%.*]] = xor i8 [[OR:%.*]], xor (i8 ptrtoint (ptr @global_constant to i8), i8 ptrtoint (ptr @global_constant2 to i8))84; CHECK-NEXT: ret i8 [[R]]85;86entry:87 %r = xor i8 %or, xor (i8 xor (i8 ptrtoint (ptr @global_constant to i8), i8 -1), i8 xor (i8 ptrtoint (ptr @global_constant2 to i8), i8 -1))88 ret i8 %r89}90 91@global_constant3 = external global [6 x [1 x i64]], align 192@global_constant4 = external global i64, align 193@global_constant5 = external global ptr, align 194 95define i16 @constantexpr2() {96; CHECK-LABEL: @constantexpr2(97; CHECK-NEXT: [[I0:%.*]] = icmp ne ptr getelementptr inbounds nuw (i8, ptr @global_constant3, i64 40), @global_constant498; CHECK-NEXT: [[I1:%.*]] = zext i1 [[I0]] to i1699; CHECK-NEXT: [[I2:%.*]] = load ptr, ptr @global_constant5, align 1100; CHECK-NEXT: [[I3:%.*]] = load i16, ptr [[I2]], align 1101; CHECK-NEXT: [[I4:%.*]] = xor i16 [[I3]], [[I1]]102; CHECK-NEXT: [[I5:%.*]] = xor i16 [[I4]], -1103; CHECK-NEXT: ret i16 [[I5]]104;105 %i0 = icmp ne ptr getelementptr inbounds ([6 x [1 x i64]], ptr @global_constant3, i16 0, i16 5, i16 0), @global_constant4106 %i1 = zext i1 %i0 to i16107 %i2 = load ptr, ptr @global_constant5, align 1108 %i3 = load i16, ptr %i2, align 1109 %i4 = xor i16 %i3, %i1110 %i5 = xor i16 %i4, -1111 ret i16 %i5112}113