xref: /llvm-project/llvm/test/CodeGen/Hexagon/arg-copy-elison.ll (revision d8b253be56b3e9073b3e59123cf2da0bcde20c63)
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 4
2; RUN: llc -mtriple hexagon-- -o - %s | FileCheck %s
3
4; Reproducer for https://github.com/llvm/llvm-project/issues/89060
5;
6; Problem was a bug in argument copy elison. Given that the %alloca is
7; eliminated, the same frame index will be used for accessing %alloca and %a
8; on the fixed stack. Care must be taken when setting up
9; MachinePointerInfo/MemOperands for those accesses to either make sure that
10; we always refer to the fixed stack slot the same way (not using the
11; ir.alloca name), or make sure that we still detect that they alias each
12; other if using different kinds of MemOperands to identify the same fixed
13; stack entry.
14;
15define i32 @f(i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 %q1, i32 %a, i32 %q2) {
16; CHECK-LABEL: f:
17; CHECK:         .cfi_startproc
18; CHECK-NEXT:  // %bb.0:
19; CHECK-NEXT:    {
20; CHECK-NEXT:     r0 = memw(r29+#36)
21; CHECK-NEXT:     r1 = memw(r29+#28)
22; CHECK-NEXT:    }
23; CHECK-NEXT:    {
24; CHECK-NEXT:     r0 = sub(r1,r0)
25; CHECK-NEXT:     r2 = memw(r29+#32)
26; CHECK-NEXT:     memw(r29+#32) = ##666
27; CHECK-NEXT:    }
28; CHECK-NEXT:    {
29; CHECK-NEXT:     r0 = xor(r0,r2)
30; CHECK-NEXT:     jumpr r31
31; CHECK-NEXT:    }
32  %alloca = alloca i32
33  store i32 %a, ptr %alloca     ; Should be elided.
34  store i32 666, ptr %alloca
35  %x = sub i32 %q1, %q2
36  %y = xor i32 %x, %a           ; Results in a load of %a from fixed stack.
37                                ; Using same frame index as elided %alloca.
38  ret i32 %y
39}
40