- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

case 1:

**if (!((a>b&&c>d)||(a<b&&c<d)))**

case 2:

**if ((a>b&&c<d)||(a<b&&c>d)||(a==b)||(c==d))**

Where, a, b, c, d are some non-NaN random double variables (between -1 and 1 in my case, I also test them with random variables generated by ippsGaussRand_Direct_64f() functions and the results for case 1 are also incorrect).

Anyone can see the above 2 experssions are of the same thing, but the complier (ICC 13.0, x86-64, highest level of optimization, Windows-64 OS) only return correct results for the second experssion, is this a bug here?

Link Copied

6 Replies

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

**ippsGaussRand_Direct_64f**to generate a, b, c and d values would help. >>...highest level of optimization... Could you post the C++ compiler command line options?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

*a,b,c,d*,

**is sufficient to prove non-equivalence. Such a test is not sufficient to prove equivalence**, given the possibility that both candidate logical expressions may yield different values for different combinations of

*a, b, c, d*. By applying Boolean Algebra rules, I come to the same conclusion as the OP, that is, the two expressions are equivalent. The next question is: Does the Intel C compiler show a bug in this regard? I ran the following test program, which makes the four real variables cover the range (-5,+5), taking steps that are slightly larger than 0.1. [cpp] #include <stdio.h> main(){ float a,b,c,d; int r1,r2; for(a=-5.0; a<=5.0; a+=0.111) for(b=-5.0; b<=5.0; b+=0.112) for(c=-5.0; c<=5.0; c+=0.113) for(d=-5.0; d<=5.0; d+=0.114){ r1 = !((a > b && c > d)||(a < b && c < d)); r2 = (a > b && c < d) || (a < b && c > d) || (a==b) || (c==d); if(r1-r2)printf("%7.1e %7.1e %7.1e %7.1e %e %e\\n",a,b,c,d,r1,r2); } } [/cpp] Running this program showed no error after compiling with the 13.0.1.119 X64 compiler with (i) options /O3 /QxAVX and (ii) the options shown above by the OP. Here is another test program, which calls IPP to generate one million sets of normally distributed values of

*a, b, c, d*, with mean = 0 and standard-deviation = 1. [cpp] #include <stdio.h> #include <ipp.h> #define NSAMP 1000000 #define LEN 4*NSAMP Ipp32f samp[LEN]; main(){ float a,b,c,d; int r1,r2,i,len=LEN; IppsRandGaussState_32f *pRandGaussState; ippsRandGaussInitAlloc_32f(&pRandGaussState, 0.0, 1.0, 162903); ippsRandGauss_32f(samp, len, pRandGaussState); for(i=0; i<NSAMP; i++){ a=samp[4*i]; b=samp[4*i+1]; c=samp[4*i+2]; d=samp[4*i+3]; r2 = !((a > b && c > d)||(a < b && c < d)); r1 = (a > b && c < d) || (a < b && c > d) || (a==b) || (c==d); if(r1-r2)printf("%7.1e %7.1e %7.1e %7.1e %e %e\\n",a,b,c,d,r1,r2); if((i+1)%10000==0)printf("%8d",(i+1)/10000); } } [/cpp] As I stated earlier, my test programs are inconclusive: no error was found for the several sets of values of

*a, b, c, d*tried in them. We need the OP to present values of

*a,b,c,d*for which an error

**is**encountered.

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page