1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2; RUN: opt < %s -passes=sccp -S | FileCheck %s 3 4define i32 @zext_lshr(i1 %t0) { 5; CHECK-LABEL: @zext_lshr( 6; CHECK-NEXT: [[T1:%.*]] = zext i1 [[T0:%.*]] to i32 7; CHECK-NEXT: ret i32 0 8; 9 %t1 = zext i1 %t0 to i32 10 %t2 = lshr i32 %t1, 1 11 ret i32 %t2 12} 13 14define i1 @zext_icmp(i1 %t0) { 15; CHECK-LABEL: @zext_icmp( 16; CHECK-NEXT: [[T1:%.*]] = zext i1 [[T0:%.*]] to i32 17; CHECK-NEXT: ret i1 false 18; 19 %t1 = zext i1 %t0 to i32 20 %t2 = icmp eq i32 %t1, 2 21 ret i1 %t2 22} 23 24; negative test. SCCP operates poorly with vector ranges 25 26define <2 x i1> @zext_vector(<2 x i1> %t0) { 27; CHECK-LABEL: @zext_vector( 28; CHECK-NEXT: [[T1:%.*]] = zext <2 x i1> [[T0:%.*]] to <2 x i32> 29; CHECK-NEXT: [[T2:%.*]] = icmp eq <2 x i32> [[T1]], <i32 2, i32 2> 30; CHECK-NEXT: ret <2 x i1> [[T2]] 31; 32 %t1 = zext <2 x i1> %t0 to <2 x i32> 33 %t2 = icmp eq <2 x i32> %t1, <i32 2, i32 2> 34 ret <2 x i1> %t2 35} 36 37; negative test. SCCP operates poorly with vector ranges 38 39define <2 x i1> @zext_vector2(<2 x i1> %t0) { 40; CHECK-LABEL: @zext_vector2( 41; CHECK-NEXT: [[T1:%.*]] = zext <2 x i1> [[T0:%.*]] to <2 x i32> 42; CHECK-NEXT: [[T2:%.*]] = add <2 x i32> [[T1]], <i32 2, i32 2> 43; CHECK-NEXT: [[T3:%.*]] = icmp eq <2 x i32> [[T1]], [[T2]] 44; CHECK-NEXT: ret <2 x i1> [[T3]] 45; 46 %t1 = zext <2 x i1> %t0 to <2 x i32> 47 %t2 = add <2 x i32> %t1, <i32 2, i32 2> 48 %t3 = icmp eq <2 x i32> %t1, %t2 49 ret <2 x i1> %t3 50} 51 52; negative test: %t2 can be replaced by %t1, but SCCP operates by ranges only 53 54define i32 @sext_ashr(i1 %t0) { 55; CHECK-LABEL: @sext_ashr( 56; CHECK-NEXT: [[T1:%.*]] = sext i1 [[T0:%.*]] to i32 57; CHECK-NEXT: [[T2:%.*]] = ashr i32 [[T1]], 1 58; CHECK-NEXT: ret i32 [[T2]] 59; 60 %t1 = sext i1 %t0 to i32 61 %t2 = ashr i32 %t1, 1 62 ret i32 %t2 63} 64 65define i1 @sext_icmp(i1 %t0) { 66; CHECK-LABEL: @sext_icmp( 67; CHECK-NEXT: [[T1:%.*]] = sext i1 [[T0:%.*]] to i32 68; CHECK-NEXT: ret i1 false 69; 70 %t1 = sext i1 %t0 to i32 71 %t2 = icmp eq i32 %t1, 2 72 ret i1 %t2 73} 74 75; negative test. SCCP operates poorly with vector ranges 76 77define <2 x i1> @sext_vector(<2 x i1> %t0) { 78; CHECK-LABEL: @sext_vector( 79; CHECK-NEXT: [[T1:%.*]] = sext <2 x i1> [[T0:%.*]] to <2 x i32> 80; CHECK-NEXT: [[T2:%.*]] = icmp eq <2 x i32> [[T1]], <i32 2, i32 2> 81; CHECK-NEXT: ret <2 x i1> [[T2]] 82; 83 %t1 = sext <2 x i1> %t0 to <2 x i32> 84 %t2 = icmp eq <2 x i32> %t1, <i32 2, i32 2> 85 ret <2 x i1> %t2 86} 87 88; negative test. SCCP operates poorly with vector ranges 89 90define <2 x i1> @sext_vector2(<2 x i1> %t0) { 91; CHECK-LABEL: @sext_vector2( 92; CHECK-NEXT: [[T1:%.*]] = sext <2 x i1> [[T0:%.*]] to <2 x i32> 93; CHECK-NEXT: [[T2:%.*]] = add <2 x i32> [[T1]], <i32 2, i32 2> 94; CHECK-NEXT: [[T3:%.*]] = icmp eq <2 x i32> [[T1]], [[T2]] 95; CHECK-NEXT: ret <2 x i1> [[T3]] 96; 97 %t1 = sext <2 x i1> %t0 to <2 x i32> 98 %t2 = add <2 x i32> %t1, <i32 2, i32 2> 99 %t3 = icmp eq <2 x i32> %t1, %t2 100 ret <2 x i1> %t3 101} 102