--- /dev/null
+/* { dg-do run { target { powerpc*-*-linux* && ilp32 } } } */
+/* { dg-options "-O2" } */
+
+/* PR 96983 reported that the test in libgcc's tramp.S was backwards and it
+ would abort if the trampoline size passed to the function was greater than
+ the size the runtime was expecting (40). It should abort if the size is less
+ than 40, not greater than 40. This test creates a call to __trampoline_setup
+ with a much larger buffer to make sure the function does not abort.
+
+ We do not run this test on 64-bit since __trampoline_setup is not present in
+ 64-bit systems.
+
+ We only run the test under Linux in case the other systems have some
+ different variant for __trampoline_setup. */
+
+#ifndef SIZE
+#define SIZE 100
+#endif
+
+extern void __trampoline_setup (int *, unsigned, void *, void *);
+
+int main (void)
+{
+ int tramp[SIZE / sizeof (int)];
+
+ __trampoline_setup (tramp, SIZE, 0, 0);
+ return 0;
+}
mflr r11
addi r7,r11,trampoline_initial-4-.LCF0 /* trampoline address -4 */
- li r8,trampoline_size /* verify that the trampoline is big enough */
- cmpw cr1,r8,r4
+ cmpwi cr1,r4,trampoline_size /* verify that the trampoline is big enough */
srwi r4,r4,2 /* # words to move */
addi r9,r3,-4 /* adjust pointer for lwzu */
mtctr r4
ld 7,.LC0@toc@l(7) /* trampoline address -8 */
#endif
- li r8,trampoline_size /* verify that the trampoline is big enough */
- cmpw cr1,r8,r4
+ cmpwi cr1,r4,trampoline_size /* verify that the trampoline is big enough */
srwi r4,r4,3 /* # doublewords to move */
addi r9,r3,-8 /* adjust pointer for stdu */
mtctr r4