• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt -mtriple=riscv32-unknown-elf -S -consthoist < %s | FileCheck %s
2; RUN: opt -mtriple=riscv64-unknown-elf -S -consthoist < %s | FileCheck %s
3
4; Check that we don't hoist immediates with small values.
5define i64 @test1(i64 %a) nounwind {
6; CHECK-LABEL: test1
7; CHECK-NOT: %const = bitcast i64 2 to i64
8  %1 = mul i64 %a, 2
9  %2 = add i64 %1, 2
10  ret i64 %2
11}
12
13; Check that we don't hoist immediates with small values.
14define i64 @test2(i64 %a) nounwind {
15; CHECK-LABEL: test2
16; CHECK-NOT: %const = bitcast i64 2047 to i64
17  %1 = mul i64 %a, 2047
18  %2 = add i64 %1, 2047
19  ret i64 %2
20}
21
22; Check that we hoist immediates with large values.
23define i64 @test3(i64 %a) nounwind {
24; CHECK-LABEL: test3
25; CHECK: %const = bitcast i64 32767 to i64
26  %1 = mul i64 %a, 32767
27  %2 = add i64 %1, 32767
28  ret i64 %2
29}
30
31; Check that we hoist immediates with very large values.
32define i128 @test4(i128 %a) nounwind {
33; CHECK-LABEL: test4
34; CHECK: %const = bitcast i128 12297829382473034410122878 to i128
35  %1 = add i128 %a, 12297829382473034410122878
36  %2 = add i128 %1, 12297829382473034410122878
37  ret i128 %2
38}
39