1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2; RUN: opt < %s -passes=instcombine -S | FileCheck %s 3 4declare i8 @gen8() 5declare void @use8(i8) 6 7@a = global i8 17 8 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]], 42 13; CHECK-NEXT: ret i8 [[R]] 14; 15 %i0 = xor i8 %x, 42 16 %r = xor i8 %i0, %y 17 ret i8 %r 18} 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, %y 28 ret <2 x i8> %r 29} 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, %y 38 ret <2 x i8> %r 39} 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, %y 48 ret <2 x i8> %r 49} 50 51define i8 @t4_extrause(i8 %x, i8 %y) { 52; CHECK-LABEL: @t4_extrause( 53; CHECK-NEXT: [[I0:%.*]] = xor i8 [[X:%.*]], 42 54; 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, 42 59 call void @use8(i8 %i0) 60 %r = xor i8 %i0, %y 61 ret i8 %r 62} 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]], 42 69; CHECK-NEXT: ret i8 [[R]] 70; 71 %i0 = xor i8 %x, 42 72 %y = call i8 @gen8() 73 %r = xor i8 %y, %i0 74 ret i8 %r 75} 76 77@global_constant = internal global i32 0, align 4 78@global_constant2 = internal global i32 0, align 4 79 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 %r 89} 90 91@global_constant3 = external global [6 x [1 x i64]], align 1 92@global_constant4 = external global i64, align 1 93@global_constant5 = external global ptr, align 1 94 95define i16 @constantexpr2() { 96; CHECK-LABEL: @constantexpr2( 97; CHECK-NEXT: [[I0:%.*]] = icmp ne ptr getelementptr inbounds nuw (i8, ptr @global_constant3, i64 40), @global_constant4 98; CHECK-NEXT: [[I1:%.*]] = zext i1 [[I0]] to i16 99; CHECK-NEXT: [[I2:%.*]] = load ptr, ptr @global_constant5, align 1 100; CHECK-NEXT: [[I3:%.*]] = load i16, ptr [[I2]], align 1 101; CHECK-NEXT: [[I4:%.*]] = xor i16 [[I3]], [[I1]] 102; CHECK-NEXT: [[I5:%.*]] = xor i16 [[I4]], -1 103; 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_constant4 106 %i1 = zext i1 %i0 to i16 107 %i2 = load ptr, ptr @global_constant5, align 1 108 %i3 = load i16, ptr %i2, align 1 109 %i4 = xor i16 %i3, %i1 110 %i5 = xor i16 %i4, -1 111 ret i16 %i5 112} 113