brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.8 KiB · a5f88bd Raw
168 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py2; RUN: opt < %s -passes=instcombine -S | FileCheck %s3 4; Fold5;   ((ptr %y) s/ %x) != %y6; to7;   @llvm.smul.with.overflow(%x, %y) + extractvalue8 9define i1 @t0_basic(i8 %x, i8 %y) {10; CHECK-LABEL: @t0_basic(11; CHECK-NEXT:    [[MUL:%.*]] = call { i8, i1 } @llvm.smul.with.overflow.i8(i8 [[X:%.*]], i8 [[Y:%.*]])12; CHECK-NEXT:    [[MUL_OV:%.*]] = extractvalue { i8, i1 } [[MUL]], 113; CHECK-NEXT:    ret i1 [[MUL_OV]]14;15  %t0 = mul i8 %x, %y16  %t1 = sdiv i8 %t0, %x17  %r = icmp ne i8 %t1, %y18  ret i1 %r19}20 21define <2 x i1> @t1_vec(<2 x i8> %x, <2 x i8> %y) {22; CHECK-LABEL: @t1_vec(23; CHECK-NEXT:    [[MUL:%.*]] = call { <2 x i8>, <2 x i1> } @llvm.smul.with.overflow.v2i8(<2 x i8> [[X:%.*]], <2 x i8> [[Y:%.*]])24; CHECK-NEXT:    [[MUL_OV:%.*]] = extractvalue { <2 x i8>, <2 x i1> } [[MUL]], 125; CHECK-NEXT:    ret <2 x i1> [[MUL_OV]]26;27  %t0 = mul <2 x i8> %x, %y28  %t1 = sdiv <2 x i8> %t0, %x29  %r = icmp ne <2 x i8> %t1, %y30  ret <2 x i1> %r31}32 33declare i8 @gen8()34 35define i1 @t2_commutative(i8 %x) {36; CHECK-LABEL: @t2_commutative(37; CHECK-NEXT:    [[Y:%.*]] = call i8 @gen8()38; CHECK-NEXT:    [[MUL:%.*]] = call { i8, i1 } @llvm.smul.with.overflow.i8(i8 [[X:%.*]], i8 [[Y]])39; CHECK-NEXT:    [[MUL_OV:%.*]] = extractvalue { i8, i1 } [[MUL]], 140; CHECK-NEXT:    ret i1 [[MUL_OV]]41;42  %y = call i8 @gen8()43  %t0 = mul i8 %y, %x ; swapped44  %t1 = sdiv i8 %t0, %x45  %r = icmp ne i8 %t1, %y46  ret i1 %r47}48 49define i1 @t3_commutative(i8 %x) {50; CHECK-LABEL: @t3_commutative(51; CHECK-NEXT:    [[Y:%.*]] = call i8 @gen8()52; CHECK-NEXT:    [[MUL:%.*]] = call { i8, i1 } @llvm.smul.with.overflow.i8(i8 [[X:%.*]], i8 [[Y]])53; CHECK-NEXT:    [[MUL_OV:%.*]] = extractvalue { i8, i1 } [[MUL]], 154; CHECK-NEXT:    ret i1 [[MUL_OV]]55;56  %y = call i8 @gen8()57  %t0 = mul i8 %y, %x ; swapped58  %t1 = sdiv i8 %t0, %x59  %r = icmp ne i8 %t1, %y60  ret i1 %r61}62 63define i1 @t4_commutative(i8 %x) {64; CHECK-LABEL: @t4_commutative(65; CHECK-NEXT:    [[Y:%.*]] = call i8 @gen8()66; CHECK-NEXT:    [[MUL:%.*]] = call { i8, i1 } @llvm.smul.with.overflow.i8(i8 [[X:%.*]], i8 [[Y]])67; CHECK-NEXT:    [[MUL_OV:%.*]] = extractvalue { i8, i1 } [[MUL]], 168; CHECK-NEXT:    ret i1 [[MUL_OV]]69;70  %y = call i8 @gen8()71  %t0 = mul i8 %y, %x ; swapped72  %t1 = sdiv i8 %t0, %x73  %r = icmp ne i8 %y, %t1 ; swapped74  ret i1 %r75}76 77; Extra-use tests78 79declare void @use8(i8)80 81define i1 @t5_extrause0(i8 %x, i8 %y) {82; CHECK-LABEL: @t5_extrause0(83; CHECK-NEXT:    [[MUL:%.*]] = call { i8, i1 } @llvm.smul.with.overflow.i8(i8 [[X:%.*]], i8 [[Y:%.*]])84; CHECK-NEXT:    [[MUL_VAL:%.*]] = extractvalue { i8, i1 } [[MUL]], 085; CHECK-NEXT:    [[MUL_OV:%.*]] = extractvalue { i8, i1 } [[MUL]], 186; CHECK-NEXT:    call void @use8(i8 [[MUL_VAL]])87; CHECK-NEXT:    ret i1 [[MUL_OV]]88;89  %t0 = mul i8 %x, %y90  call void @use8(i8 %t0)91  %t1 = sdiv i8 %t0, %x92  %r = icmp ne i8 %t1, %y93  ret i1 %r94}95 96define i1 @t6_extrause1(i8 %x, i8 %y) {97; CHECK-LABEL: @t6_extrause1(98; CHECK-NEXT:    [[T0:%.*]] = mul i8 [[X:%.*]], [[Y:%.*]]99; CHECK-NEXT:    [[T1:%.*]] = sdiv i8 [[T0]], [[X]]100; CHECK-NEXT:    call void @use8(i8 [[T1]])101; CHECK-NEXT:    [[R:%.*]] = icmp ne i8 [[T1]], [[Y]]102; CHECK-NEXT:    ret i1 [[R]]103;104  %t0 = mul i8 %x, %y105  %t1 = sdiv i8 %t0, %x106  call void @use8(i8 %t1)107  %r = icmp ne i8 %t1, %y108  ret i1 %r109}110 111define i1 @t7_extrause2(i8 %x, i8 %y) {112; CHECK-LABEL: @t7_extrause2(113; CHECK-NEXT:    [[T0:%.*]] = mul i8 [[X:%.*]], [[Y:%.*]]114; CHECK-NEXT:    call void @use8(i8 [[T0]])115; CHECK-NEXT:    [[T1:%.*]] = sdiv i8 [[T0]], [[X]]116; CHECK-NEXT:    call void @use8(i8 [[T1]])117; CHECK-NEXT:    [[R:%.*]] = icmp ne i8 [[T1]], [[Y]]118; CHECK-NEXT:    ret i1 [[R]]119;120  %t0 = mul i8 %x, %y121  call void @use8(i8 %t0)122  %t1 = sdiv i8 %t0, %x123  call void @use8(i8 %t1)124  %r = icmp ne i8 %t1, %y125  ret i1 %r126}127 128; Negative tests129 130define i1 @n8_different_x(i8 %x0, i8 %x1, i8 %y) {131; CHECK-LABEL: @n8_different_x(132; CHECK-NEXT:    [[T0:%.*]] = mul i8 [[X0:%.*]], [[Y:%.*]]133; CHECK-NEXT:    [[T1:%.*]] = sdiv i8 [[T0]], [[X1:%.*]]134; CHECK-NEXT:    [[R:%.*]] = icmp ne i8 [[T1]], [[Y]]135; CHECK-NEXT:    ret i1 [[R]]136;137  %t0 = mul i8 %x0, %y138  %t1 = sdiv i8 %t0, %x1139  %r = icmp ne i8 %t1, %y140  ret i1 %r141}142 143define i1 @n9_different_y(i8 %x, i8 %y0, i8 %y1) {144; CHECK-LABEL: @n9_different_y(145; CHECK-NEXT:    [[T0:%.*]] = mul i8 [[X:%.*]], [[Y0:%.*]]146; CHECK-NEXT:    [[T1:%.*]] = sdiv i8 [[T0]], [[X]]147; CHECK-NEXT:    [[R:%.*]] = icmp ne i8 [[T1]], [[Y1:%.*]]148; CHECK-NEXT:    ret i1 [[R]]149;150  %t0 = mul i8 %x, %y0151  %t1 = sdiv i8 %t0, %x152  %r = icmp ne i8 %t1, %y1153  ret i1 %r154}155 156define i1 @n10_wrong_pred(i8 %x, i8 %y) {157; CHECK-LABEL: @n10_wrong_pred(158; CHECK-NEXT:    [[T0:%.*]] = mul i8 [[X:%.*]], [[Y:%.*]]159; CHECK-NEXT:    [[T1:%.*]] = sdiv i8 [[T0]], [[X]]160; CHECK-NEXT:    [[R:%.*]] = icmp ugt i8 [[T1]], [[Y]]161; CHECK-NEXT:    ret i1 [[R]]162;163  %t0 = mul i8 %x, %y164  %t1 = sdiv i8 %t0, %x165  %r = icmp ugt i8 %t1, %y166  ret i1 %r167}168