• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt < %s -instsimplify -S | FileCheck %s
3
4define i32 @negated_operand(i32 %x) {
5; CHECK-LABEL: @negated_operand(
6; CHECK-NEXT:    ret i32 0
7;
8  %negx = sub i32 0, %x
9  %rem = srem i32 %negx, %x
10  ret i32 %rem
11}
12
13define <2 x i32> @negated_operand_commute_vec(<2 x i32> %x) {
14; CHECK-LABEL: @negated_operand_commute_vec(
15; CHECK-NEXT:    ret <2 x i32> zeroinitializer
16;
17  %negx = sub <2 x i32> zeroinitializer, %x
18  %rem = srem <2 x i32> %negx, %x
19  ret <2 x i32> %rem
20}
21
22define i32 @knownnegation(i32 %x, i32 %y) {
23; CHECK-LABEL: @knownnegation(
24; CHECK-NEXT:    ret i32 0
25;
26  %xy = sub i32 %x, %y
27  %yx = sub i32 %y, %x
28  %rem = srem i32 %xy, %yx
29  ret i32 %rem
30}
31
32define <2 x i32> @knownnegation_commute_vec(<2 x i32> %x, <2 x i32> %y) {
33; CHECK-LABEL: @knownnegation_commute_vec(
34; CHECK-NEXT:    ret <2 x i32> zeroinitializer
35;
36  %xy = sub <2 x i32> %x, %y
37  %yx = sub <2 x i32> %y, %x
38  %rem = srem <2 x i32> %xy, %yx
39  ret <2 x i32> %rem
40}
41
42define <3 x i32> @negated_operand_vec_undef(<3 x i32> %x) {
43; CHECK-LABEL: @negated_operand_vec_undef(
44; CHECK-NEXT:    ret <3 x i32> zeroinitializer
45;
46  %negx = sub <3 x i32> <i32 0, i32 undef, i32 0>, %x
47  %rem = srem <3 x i32> %negx, %x
48  ret <3 x i32> %rem
49}
50
51define <2 x i32> @negated_operand_vec_nonsplat(<2 x i32> %x) {
52; CHECK-LABEL: @negated_operand_vec_nonsplat(
53; CHECK-NEXT:    [[NEGX:%.*]] = sub <2 x i32> <i32 0, i32 1>, [[X:%.*]]
54; CHECK-NEXT:    [[REM:%.*]] = srem <2 x i32> [[NEGX]], [[X]]
55; CHECK-NEXT:    ret <2 x i32> [[REM]]
56;
57  %negx = sub <2 x i32> <i32 0, i32 1>, %x ; not 0, don't fold
58  %rem = srem <2 x i32> %negx, %x
59  ret <2 x i32> %rem
60}
61
62define i32 @negated_operand_commute(i32 %x) {
63; CHECK-LABEL: @negated_operand_commute(
64; CHECK-NEXT:    ret i32 0
65;
66  %negx = sub i32 0, %x
67  %rem = srem i32 %x, %negx
68  ret i32 %rem
69}
70