1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2; RUN: opt < %s -instcombine -S | FileCheck %s 3 4; Fold 5; x s/EXACT (1 << y) 6; to 7; x a>>EXACT y 8; iff 1<<y is non-negative 9 10define i8 @t0(i8 %x) { 11; CHECK-LABEL: @t0( 12; CHECK-NEXT: [[DIV:%.*]] = ashr exact i8 [[X:%.*]], 5 13; CHECK-NEXT: ret i8 [[DIV]] 14; 15 %div = sdiv exact i8 %x, 32 16 ret i8 %div 17} 18define i8 @n1(i8 %x) { 19; CHECK-LABEL: @n1( 20; CHECK-NEXT: [[DIV:%.*]] = sdiv i8 [[X:%.*]], 32 21; CHECK-NEXT: ret i8 [[DIV]] 22; 23 %div = sdiv i8 %x, 32 ; not exact 24 ret i8 %div 25} 26define i8 @n2(i8 %x) { 27; CHECK-LABEL: @n2( 28; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i8 [[X:%.*]], -128 29; CHECK-NEXT: [[DIV:%.*]] = zext i1 [[TMP1]] to i8 30; CHECK-NEXT: ret i8 [[DIV]] 31; 32 %div = sdiv i8 %x, 128 ; negative divisor 33 ret i8 %div 34} 35 36define <2 x i8> @t3_vec_splat(<2 x i8> %x) { 37; CHECK-LABEL: @t3_vec_splat( 38; CHECK-NEXT: [[DIV:%.*]] = ashr exact <2 x i8> [[X:%.*]], <i8 5, i8 5> 39; CHECK-NEXT: ret <2 x i8> [[DIV]] 40; 41 %div = sdiv exact <2 x i8> %x, <i8 32, i8 32> 42 ret <2 x i8> %div 43} 44 45define <2 x i8> @t4_vec(<2 x i8> %x) { 46; CHECK-LABEL: @t4_vec( 47; CHECK-NEXT: [[DIV:%.*]] = ashr exact <2 x i8> [[X:%.*]], <i8 5, i8 4> 48; CHECK-NEXT: ret <2 x i8> [[DIV]] 49; 50 %div = sdiv exact <2 x i8> %x, <i8 32, i8 16> 51 ret <2 x i8> %div 52} 53 54define <2 x i8> @n5_vec_undef(<2 x i8> %x) { 55; CHECK-LABEL: @n5_vec_undef( 56; CHECK-NEXT: ret <2 x i8> undef 57; 58 %div = sdiv exact <2 x i8> %x, <i8 32, i8 undef> 59 ret <2 x i8> %div 60} 61define <2 x i8> @n6_vec_negative(<2 x i8> %x) { 62; CHECK-LABEL: @n6_vec_negative( 63; CHECK-NEXT: [[DIV:%.*]] = sdiv exact <2 x i8> [[X:%.*]], <i8 32, i8 -128> 64; CHECK-NEXT: ret <2 x i8> [[DIV]] 65; 66 %div = sdiv exact <2 x i8> %x, <i8 32, i8 128> ; non-non-negative divisor 67 ret <2 x i8> %div 68} 69