# Changeset View

Changeset View

# Standalone View

Standalone View

# llvm/trunk/test/Transforms/InstCombine/operand-complexity.ll

1 | ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py | 1 | ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py | ||
---|---|---|---|---|---|

2 | ; RUN: opt < %s -instcombine -S | FileCheck %s | 2 | ; RUN: opt < %s -instcombine -S | FileCheck %s | ||

3 | 3 | | |||

4 | ; 'Negate' is considered less complex than a normal binop, so the mul should have the binop as the first operand. | 4 | ; 'Negate' is considered less complex than a normal binop, so the mul should have the binop as the first operand. | ||

5 | 5 | | |||

6 | define i8 @neg(i8 %x) { | 6 | define i8 @neg(i8 %x) { | ||

7 | ; CHECK-LABEL: @neg( | 7 | ; CHECK-LABEL: @neg( | ||

8 | ; CHECK-NEXT: [[BO:%.*]] = udiv i8 [[X:%.*]], 42 | 8 | ; CHECK-NEXT: [[BO:%.*]] = udiv i8 [[X:%.*]], 42 | ||

9 | ; CHECK-NEXT: [[NEGX:%.*]] = sub i8 0, [[X]] | 9 | ; CHECK-NEXT: [[NEGX:%.*]] = sub i8 0, [[X]] | ||

10 | ; CHECK-NEXT: [[R:%.*]] = mul i8 [[BO]], [[NEGX]] | 10 | ; CHECK-NEXT: [[R:%.*]] = xor i8 [[BO]], [[NEGX]] | ||

11 | ; CHECK-NEXT: ret i8 [[R]] | 11 | ; CHECK-NEXT: ret i8 [[R]] | ||

12 | ; | 12 | ; | ||

13 | %bo = udiv i8 %x, 42 | 13 | %bo = udiv i8 %x, 42 | ||

14 | %negx = sub i8 0, %x | 14 | %negx = sub i8 0, %x | ||

15 | %r = mul i8 %negx, %bo | 15 | %r = xor i8 %negx, %bo | ||

16 | ret i8 %r | 16 | ret i8 %r | ||

17 | } | 17 | } | ||

18 | 18 | | |||

19 | define <2 x i8> @neg_vec(<2 x i8> %x) { | 19 | define <2 x i8> @neg_vec(<2 x i8> %x) { | ||

20 | ; CHECK-LABEL: @neg_vec( | 20 | ; CHECK-LABEL: @neg_vec( | ||

21 | ; CHECK-NEXT: [[BO:%.*]] = udiv <2 x i8> [[X:%.*]], <i8 42, i8 -42> | 21 | ; CHECK-NEXT: [[BO:%.*]] = udiv <2 x i8> [[X:%.*]], <i8 42, i8 -42> | ||

22 | ; CHECK-NEXT: [[NEGX:%.*]] = sub <2 x i8> zeroinitializer, [[X]] | 22 | ; CHECK-NEXT: [[NEGX:%.*]] = sub <2 x i8> zeroinitializer, [[X]] | ||

23 | ; CHECK-NEXT: [[R:%.*]] = mul <2 x i8> [[BO]], [[NEGX]] | 23 | ; CHECK-NEXT: [[R:%.*]] = xor <2 x i8> [[BO]], [[NEGX]] | ||

24 | ; CHECK-NEXT: ret <2 x i8> [[R]] | 24 | ; CHECK-NEXT: ret <2 x i8> [[R]] | ||

25 | ; | 25 | ; | ||

26 | %bo = udiv <2 x i8> %x, <i8 42, i8 -42> | 26 | %bo = udiv <2 x i8> %x, <i8 42, i8 -42> | ||

27 | %negx = sub <2 x i8> <i8 0, i8 0>, %x | 27 | %negx = sub <2 x i8> <i8 0, i8 0>, %x | ||

28 | %r = mul <2 x i8> %negx, %bo | 28 | %r = xor <2 x i8> %negx, %bo | ||

29 | ret <2 x i8> %r | 29 | ret <2 x i8> %r | ||

30 | } | 30 | } | ||

31 | 31 | | |||

32 | define <2 x i8> @neg_vec_undef(<2 x i8> %x) { | 32 | define <2 x i8> @neg_vec_undef(<2 x i8> %x) { | ||

33 | ; CHECK-LABEL: @neg_vec_undef( | 33 | ; CHECK-LABEL: @neg_vec_undef( | ||

34 | ; CHECK-NEXT: [[BO:%.*]] = udiv <2 x i8> [[X:%.*]], <i8 42, i8 -42> | 34 | ; CHECK-NEXT: [[BO:%.*]] = udiv <2 x i8> [[X:%.*]], <i8 42, i8 -42> | ||

35 | ; CHECK-NEXT: [[NEGX:%.*]] = sub <2 x i8> <i8 0, i8 undef>, [[X]] | 35 | ; CHECK-NEXT: [[NEGX:%.*]] = sub <2 x i8> <i8 0, i8 undef>, [[X]] | ||

36 | ; CHECK-NEXT: [[R:%.*]] = mul <2 x i8> [[BO]], [[NEGX]] | 36 | ; CHECK-NEXT: [[R:%.*]] = xor <2 x i8> [[BO]], [[NEGX]] | ||

37 | ; CHECK-NEXT: ret <2 x i8> [[R]] | 37 | ; CHECK-NEXT: ret <2 x i8> [[R]] | ||

38 | ; | 38 | ; | ||

39 | %bo = udiv <2 x i8> %x, <i8 42, i8 -42> | 39 | %bo = udiv <2 x i8> %x, <i8 42, i8 -42> | ||

40 | %negx = sub <2 x i8> <i8 0, i8 undef>, %x | 40 | %negx = sub <2 x i8> <i8 0, i8 undef>, %x | ||

41 | %r = mul <2 x i8> %negx, %bo | 41 | %r = xor <2 x i8> %negx, %bo | ||

42 | ret <2 x i8> %r | 42 | ret <2 x i8> %r | ||

43 | } | 43 | } | ||

44 | 44 | | |||

45 | ; 'Not' is considered less complex than a normal binop, so the mul should have the binop as the first operand. | 45 | ; 'Not' is considered less complex than a normal binop, so the mul should have the binop as the first operand. | ||

46 | 46 | | |||

47 | define i8 @not(i8 %x) { | 47 | define i8 @not(i8 %x) { | ||

48 | ; CHECK-LABEL: @not( | 48 | ; CHECK-LABEL: @not( | ||

49 | ; CHECK-NEXT: [[BO:%.*]] = udiv i8 [[X:%.*]], 42 | 49 | ; CHECK-NEXT: [[BO:%.*]] = udiv i8 [[X:%.*]], 42 | ||

▲ Show 20 Lines • Show All 87 Lines • Show Last 20 Lines |