1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -newgvn -S < %s | FileCheck %s
4 declare void @use(i32, i32)
6 define void @binop(i32 %x, i32 %y) {
8 ; CHECK-NEXT: [[ADD1:%.*]] = add i32 [[X:%.*]], [[Y:%.*]]
9 ; CHECK-NEXT: call void @use(i32 [[ADD1]], i32 [[ADD1]])
10 ; CHECK-NEXT: ret void
12 %add1 = add i32 %x, %y
13 %add2 = add i32 %y, %x
14 call void @use(i32 %add1, i32 %add2)
18 declare void @vse(i1, i1)
20 define void @cmp(i32 %x, i32 %y) {
22 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ult i32 [[X:%.*]], [[Y:%.*]]
23 ; CHECK-NEXT: call void @vse(i1 [[CMP1]], i1 [[CMP1]])
24 ; CHECK-NEXT: ret void
26 %cmp1 = icmp ult i32 %x, %y
27 %cmp2 = icmp ugt i32 %y, %x
28 call void @vse(i1 %cmp1, i1 %cmp2)
32 declare i32 @llvm.smax.i32(i32, i32)
34 define void @intrinsic(i32 %x, i32 %y) {
35 ; CHECK-LABEL: @intrinsic(
36 ; CHECK-NEXT: [[M1:%.*]] = call i32 @llvm.smax.i32(i32 [[X:%.*]], i32 [[Y:%.*]])
37 ; CHECK-NEXT: [[M2:%.*]] = call i32 @llvm.smax.i32(i32 [[Y]], i32 [[X]])
38 ; CHECK-NEXT: call void @use(i32 [[M1]], i32 [[M2]])
39 ; CHECK-NEXT: ret void
41 %m1 = call i32 @llvm.smax.i32(i32 %x, i32 %y)
42 %m2 = call i32 @llvm.smax.i32(i32 %y, i32 %x)
43 call void @use(i32 %m1, i32 %m2)
47 declare i16 @llvm.smul.fix.i16(i16, i16, i32)
48 declare i16 @llvm.umul.fix.i16(i16, i16, i32)
50 define i16 @intrinsic_3_args(i16 %x, i16 %y) {
51 ; CHECK-LABEL: @intrinsic_3_args(
52 ; CHECK-NEXT: [[M1:%.*]] = call i16 @llvm.smul.fix.i16(i16 [[X:%.*]], i16 [[Y:%.*]], i32 1)
53 ; CHECK-NEXT: [[M2:%.*]] = call i16 @llvm.smul.fix.i16(i16 [[Y]], i16 [[X]], i32 1)
54 ; CHECK-NEXT: [[R:%.*]] = sub i16 [[M1]], [[M2]]
55 ; CHECK-NEXT: ret i16 [[R]]
57 %m1 = call i16 @llvm.smul.fix.i16(i16 %x, i16 %y, i32 1)
58 %m2 = call i16 @llvm.smul.fix.i16(i16 %y, i16 %x, i32 1)
63 define i16 @intrinsic_3_args_not_same(i16 %x, i16 %y) {
64 ; CHECK-LABEL: @intrinsic_3_args_not_same(
65 ; CHECK-NEXT: [[M1:%.*]] = call i16 @llvm.umul.fix.i16(i16 [[X:%.*]], i16 [[Y:%.*]], i32 2)
66 ; CHECK-NEXT: [[M2:%.*]] = call i16 @llvm.umul.fix.i16(i16 [[Y]], i16 [[X]], i32 1)
67 ; CHECK-NEXT: [[R:%.*]] = sub i16 [[M1]], [[M2]]
68 ; CHECK-NEXT: ret i16 [[R]]
70 %m1 = call i16 @llvm.umul.fix.i16(i16 %x, i16 %y, i32 2)
71 %m2 = call i16 @llvm.umul.fix.i16(i16 %y, i16 %x, i32 1)
76 declare float @llvm.fma.f32(float, float, float)
78 define float @fma(float %x, float %y) {
80 ; CHECK-NEXT: [[M1:%.*]] = call float @llvm.fma.f32(float [[X:%.*]], float [[Y:%.*]], float 1.000000e+00)
81 ; CHECK-NEXT: [[M2:%.*]] = call float @llvm.fma.f32(float [[Y]], float [[X]], float 1.000000e+00)
82 ; CHECK-NEXT: [[R:%.*]] = fdiv nnan float [[M1]], [[M2]]
83 ; CHECK-NEXT: ret float [[R]]
85 %m1 = call float @llvm.fma.f32(float %x, float %y, float 1.0)
86 %m2 = call float @llvm.fma.f32(float %y, float %x, float 1.0)
87 %r = fdiv nnan float %m1, %m2