1 ; Check if we can evaluate a bitcasted call to a function which is constant folded.
2 ; Evaluator folds call to fmodf, replacing it with constant value in case both operands
3 ; are known at compile time.
4 ; RUN: opt -globalopt -instcombine %s -S -o - | FileCheck %s
6 ; CHECK: @_q = dso_local local_unnamed_addr global %struct.Q { i32 1066527622 }
7 ; CHECK: define dso_local i32 @main
8 ; CHECK-NEXT: %[[V:.+]] = load i32, i32* getelementptr inbounds (%struct.Q, %struct.Q* @_q, i64 0, i32 0)
9 ; CHECK-NEXT: ret i32 %[[V]]
11 source_filename = "main.cpp"
12 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
13 target triple = "x86_64-none-linux-gnu"
15 %struct.Q = type { i32 }
17 $_ZN1QC2Ev = comdat any
19 @_q = dso_local global %struct.Q zeroinitializer, align 4
20 @llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__sub_I_main.cpp, i8* null }]
22 define internal void @__cxx_global_var_init() section ".text.startup" {
23 call void @_ZN1QC2Ev(%struct.Q* @_q)
27 define linkonce_odr dso_local void @_ZN1QC2Ev(%struct.Q*) unnamed_addr #1 comdat align 2 {
28 %2 = alloca %struct.Q*, align 8
29 store %struct.Q* %0, %struct.Q** %2, align 8
30 %3 = load %struct.Q*, %struct.Q** %2, align 8
31 %4 = getelementptr inbounds %struct.Q, %struct.Q* %3, i32 0, i32 0
32 %5 = call i32 bitcast (float (float, float)* @fmodf to i32 (float, float)*)(float 0x40091EB860000000, float 2.000000e+00)
33 store i32 %5, i32* %4, align 4
37 define dso_local i32 @main(i32, i8**) {
38 %3 = alloca i32, align 4
39 %4 = alloca i32, align 4
40 %5 = alloca i8**, align 8
41 store i32 0, i32* %3, align 4
42 store i32 %0, i32* %4, align 4
43 store i8** %1, i8*** %5, align 8
44 %6 = load i32, i32* getelementptr inbounds (%struct.Q, %struct.Q* @_q, i32 0, i32 0), align 4
48 ; Function Attrs: nounwind
49 declare dso_local float @fmodf(float, float)
51 ; Function Attrs: noinline uwtable
52 define internal void @_GLOBAL__sub_I_main.cpp() section ".text.startup" {
53 call void @__cxx_global_var_init()