diff mbox series

Re: trapv question

Message ID cc0dbbe1-5cb8-045c-5c6e-2d25337341b4@redhat.com
State New
Headers show
Series Re: trapv question | expand

Commit Message

Andrew MacLeod Jan. 20, 2021, 9:32 p.m. UTC
On 1/20/21 1:43 PM, Richard Biener wrote:
> On January 20, 2021 6:52:11 PM GMT+01:00, Andrew MacLeod <amacleod@redhat.com> wrote:
>
>> diff --git a/gcc/testsuite/gcc.dg/torture/ftrapv-2.c
>> b/gcc/testsuite/gcc.dg/torture/ftrapv-2.c
>> index 75e464fe557..5824c2fdbb7 100644
>> --- a/gcc/testsuite/gcc.dg/torture/ftrapv-2.c
>> +++ b/gcc/testsuite/gcc.dg/torture/ftrapv-2.c
>> @@ -20,7 +20,7 @@ int main(void)
>>     int status = 0;
>>     if (child == 0)
>>       {
>> -      volatile int x = i + 1 < i;
>> +      i = i + 1;
> But i should then be volatile which should make it LTO proof as well. Otherwise this looks OK.
>
> Richard.
>
>
>>         exit (0);
>>       }
>>     else if (child == -1)
>>
>>
>> Is that the right thing to do?
>>
>> THanks
>> Andrew


Done... pushed
commit 842afc4e289ed3fe69583672c1a180f268d73799
Author: Andrew MacLeod <amacleod@redhat.com>
Date:   Wed Jan 20 16:27:34 2021 -0500

    Re: trapv question
    
    Adjust testcase to so the ADD that is expected to overflow cannot
    be optimized.
    
            gcc/testsuite
            * gcc.dg/torture/ftrapv-2.c: Make overflow instruction unremovable.
diff mbox series

Patch

diff --git a/gcc/testsuite/gcc.dg/torture/ftrapv-2.c b/gcc/testsuite/gcc.dg/torture/ftrapv-2.c
index 75e464fe557..4d746c9ce5c 100644
--- a/gcc/testsuite/gcc.dg/torture/ftrapv-2.c
+++ b/gcc/testsuite/gcc.dg/torture/ftrapv-2.c
@@ -12,7 +12,7 @@ 
 
 /* Verify SImode operations properly trap.  PR middle-end/68046 */
 
-int i = 0x7fffffff;
+volatile int i = 0x7fffffff;
 
 int main(void)
 {
@@ -20,7 +20,7 @@  int main(void)
   int status = 0;
   if (child == 0)
     {
-      volatile int x = i + 1 < i;
+      i = i + 1;
       exit (0);
     }
   else if (child == -1)