xref: /llvm-project/llvm/test/CodeGen/X86/store_op_load_fold.ll (revision 3ad2399148953837622d78d18ae9fd0db6ad0557)
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc < %s -mtriple=i686-darwin | FileCheck %s
3;
4; Test the add and load are folded into the store instruction.
5
6@X = internal global i16 0              ; <ptr> [#uses=2]
7
8define void @foo() nounwind {
9; CHECK-LABEL: foo:
10; CHECK:       ## %bb.0:
11; CHECK-NEXT:    addw $329, _X ## imm = 0x149
12; CHECK-NEXT:    retl
13  %tmp.0 = load i16, ptr @X           ; <i16> [#uses=1]
14  %tmp.3 = add i16 %tmp.0, 329            ; <i16> [#uses=1]
15  store i16 %tmp.3, ptr @X
16  ret void
17}
18
19; rdar://12838504
20%struct.S2 = type { i64, i16, [2 x i8], i8, [3 x i8], [7 x i8], i8, [8 x i8] }
21@s2 = external global %struct.S2, align 16
22define void @test2() nounwind uwtable ssp {
23; CHECK-LABEL: test2:
24; CHECK:       ## %bb.0:
25; CHECK-NEXT:    movl L_s2$non_lazy_ptr, %eax
26; CHECK-NEXT:    andl $-67108609, 19(%eax) ## imm = 0xFC0000FF
27; CHECK-NEXT:    retl
28  %bf.load35 = load i56, ptr getelementptr inbounds (%struct.S2, ptr @s2, i32 0, i32 5), align 16
29  %bf.clear36 = and i56 %bf.load35, -1125895611875329
30  store i56 %bf.clear36, ptr getelementptr inbounds (%struct.S2, ptr @s2, i32 0, i32 5), align 16
31  ret void
32}
33