xref: /llvm-project/llvm/test/Transforms/MergeFunc/constant-entire-value.ll (revision f38f99bd7671cee44c2a6a751fcab8685dbc3996)
1*f38f99bdSRoman Lebedev; RUN: opt -S -passes=mergefunc < %s | FileCheck %s
2cee313d2SEric Christopher
3*f38f99bdSRoman Lebedev; RUN: opt -S -passes=mergefunc < %s | FileCheck -check-prefix=NOPLUS %s
4cee313d2SEric Christopher
5cee313d2SEric Christopher; This makes sure that zeros in constants don't cause problems with string based
6cee313d2SEric Christopher; memory comparisons
7cee313d2SEric Christopherdefine internal i32 @sum(i32 %x, i32 %y) {
8cee313d2SEric Christopher; CHECK-LABEL: @sum
9cee313d2SEric Christopher  %sum = add i32 %x, %y
10cee313d2SEric Christopher  %1 = extractvalue [3 x i32] [ i32 3, i32 0, i32 2 ], 2
11cee313d2SEric Christopher  %sum2 = add i32 %sum, %1
12cee313d2SEric Christopher  %sum3 = add i32 %sum2, %y
13cee313d2SEric Christopher  ret i32 %sum3
14cee313d2SEric Christopher}
15cee313d2SEric Christopher
16cee313d2SEric Christopherdefine internal i32 @add(i32 %x, i32 %y) {
17cee313d2SEric Christopher; CHECK-LABEL: @add
18cee313d2SEric Christopher  %sum = add i32 %x, %y
19cee313d2SEric Christopher  %1 = extractvalue [3 x i32] [ i32 3, i32 0, i32 1 ], 2
20cee313d2SEric Christopher  %sum2 = add i32 %sum, %1
21cee313d2SEric Christopher  %sum3 = add i32 %sum2, %y
22cee313d2SEric Christopher  ret i32 %sum3
23cee313d2SEric Christopher}
24cee313d2SEric Christopher
25cee313d2SEric Christopherdefine internal i32 @plus(i32 %x, i32 %y) {
26cee313d2SEric Christopher; NOPLUS-NOT: @plus
27cee313d2SEric Christopher  %sum = add i32 %x, %y
28cee313d2SEric Christopher  %1 = extractvalue [3 x i32] [ i32 3, i32 0, i32 5 ], 2
29cee313d2SEric Christopher  %sum2 = add i32 %sum, %1
30cee313d2SEric Christopher  %sum3 = add i32 %sum2, %y
31cee313d2SEric Christopher  ret i32 %sum3
32cee313d2SEric Christopher}
33cee313d2SEric Christopher
34cee313d2SEric Christopherdefine internal i32 @next(i32 %x, i32 %y) {
35cee313d2SEric Christopher; CHECK-LABEL: @next
36cee313d2SEric Christopher  %sum = add i32 %x, %y
37cee313d2SEric Christopher  %1 = extractvalue [3 x i32] [ i32 3, i32 0, i32 5 ], 2
38cee313d2SEric Christopher  %sum2 = add i32 %sum, %1
39cee313d2SEric Christopher  %sum3 = add i32 %sum2, %y
40cee313d2SEric Christopher  ret i32 %sum3
41cee313d2SEric Christopher}
42cee313d2SEric Christopher
43