1 /* { dg-do compile } */
2 /* { dg-options "-O1 -fdump-rtl-loop2_invariant" } */
3 /* { dg-skip-if "unexpected IV" { "hppa*-*-* mips*-*-* visium-*-* powerpc*-*-* riscv*-*-* mmix-*-* vax-*-*" } } */
4 /* Load immediate on condition is available from z13 on and prevents moving
5 the load out of the loop, so always run this test with -march=zEC12 that
6 does not have load immediate on condition. */
7 /* { dg-additional-options "-march=zEC12" { target { s390*-*-* } } } */
8
9 void
f(int * a,int * b)10 f (int *a, int *b)
11 {
12 int i;
13
14 for (i = 0; i < 100; i++)
15 {
16 int d = 42;
17
18 a[i] = d;
19 if (i % 2)
20 d = i;
21 b[i] = d;
22 }
23 }
24
25 /* Load of 42 is moved out of the loop, introducing a new pseudo register. */
26 /* { dg-final { scan-rtl-dump-times "Decided" 1 "loop2_invariant" } } */
27 /* { dg-final { scan-rtl-dump-not "without introducing a new temporary register" "loop2_invariant" } } */
28
29