summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/torture
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gcc.dg/torture')
-rw-r--r--gcc/testsuite/gcc.dg/torture/20080716-1.c58
-rw-r--r--gcc/testsuite/gcc.dg/torture/20090618-1.c25
-rw-r--r--gcc/testsuite/gcc.dg/torture/arm-fp16-compile-assign.c29
-rw-r--r--gcc/testsuite/gcc.dg/torture/arm-fp16-compile-convert.c41
-rw-r--r--gcc/testsuite/gcc.dg/torture/arm-fp16-int-convert-alt.c17
-rw-r--r--gcc/testsuite/gcc.dg/torture/arm-fp16-int-convert-ieee.c17
-rw-r--r--gcc/testsuite/gcc.dg/torture/arm-fp16-ops-1.c5
-rw-r--r--gcc/testsuite/gcc.dg/torture/arm-fp16-ops-2.c5
-rw-r--r--gcc/testsuite/gcc.dg/torture/arm-fp16-ops-3.c5
-rw-r--r--gcc/testsuite/gcc.dg/torture/arm-fp16-ops-4.c5
-rw-r--r--gcc/testsuite/gcc.dg/torture/arm-fp16-ops-5.c15
-rw-r--r--gcc/testsuite/gcc.dg/torture/arm-fp16-ops-6.c15
-rw-r--r--gcc/testsuite/gcc.dg/torture/arm-fp16-ops-7.c13
-rw-r--r--gcc/testsuite/gcc.dg/torture/arm-fp16-ops-8.c13
-rw-r--r--gcc/testsuite/gcc.dg/torture/arm-fp16-ops.h135
-rw-r--r--gcc/testsuite/gcc.dg/torture/asm-subreg-1.c15
-rw-r--r--gcc/testsuite/gcc.dg/torture/badshift.c29
-rw-r--r--gcc/testsuite/gcc.dg/torture/builtin-attr-1.c435
-rw-r--r--gcc/testsuite/gcc.dg/torture/builtin-convert-1.c149
-rw-r--r--gcc/testsuite/gcc.dg/torture/builtin-convert-2.c78
-rw-r--r--gcc/testsuite/gcc.dg/torture/builtin-convert-3.c61
-rw-r--r--gcc/testsuite/gcc.dg/torture/builtin-convert-4.c36
-rw-r--r--gcc/testsuite/gcc.dg/torture/builtin-cproj-1.c247
-rw-r--r--gcc/testsuite/gcc.dg/torture/builtin-cproj-2.c46
-rw-r--r--gcc/testsuite/gcc.dg/torture/builtin-ctype-1.c44
-rw-r--r--gcc/testsuite/gcc.dg/torture/builtin-ctype-2.c107
-rw-r--r--gcc/testsuite/gcc.dg/torture/builtin-explog-1.c231
-rw-r--r--gcc/testsuite/gcc.dg/torture/builtin-frexp-1.c137
-rw-r--r--gcc/testsuite/gcc.dg/torture/builtin-integral-1.c69
-rw-r--r--gcc/testsuite/gcc.dg/torture/builtin-isinf_sign-1.c56
-rw-r--r--gcc/testsuite/gcc.dg/torture/builtin-ldexp-1.c216
-rw-r--r--gcc/testsuite/gcc.dg/torture/builtin-logb-1.c192
-rw-r--r--gcc/testsuite/gcc.dg/torture/builtin-math-1.c186
-rw-r--r--gcc/testsuite/gcc.dg/torture/builtin-math-2.c385
-rw-r--r--gcc/testsuite/gcc.dg/torture/builtin-math-3.c374
-rw-r--r--gcc/testsuite/gcc.dg/torture/builtin-math-4.c311
-rw-r--r--gcc/testsuite/gcc.dg/torture/builtin-math-5.c123
-rw-r--r--gcc/testsuite/gcc.dg/torture/builtin-math-6.c302
-rw-r--r--gcc/testsuite/gcc.dg/torture/builtin-math-7.c99
-rw-r--r--gcc/testsuite/gcc.dg/torture/builtin-math-8.c34
-rw-r--r--gcc/testsuite/gcc.dg/torture/builtin-minmax-1.c128
-rw-r--r--gcc/testsuite/gcc.dg/torture/builtin-modf-1.c195
-rw-r--r--gcc/testsuite/gcc.dg/torture/builtin-nonneg-1.c180
-rw-r--r--gcc/testsuite/gcc.dg/torture/builtin-noret-1.c79
-rw-r--r--gcc/testsuite/gcc.dg/torture/builtin-noret-2.c89
-rw-r--r--gcc/testsuite/gcc.dg/torture/builtin-pow-mpfr-1.c19
-rw-r--r--gcc/testsuite/gcc.dg/torture/builtin-power-1.c113
-rw-r--r--gcc/testsuite/gcc.dg/torture/builtin-rounding-1.c120
-rw-r--r--gcc/testsuite/gcc.dg/torture/builtin-sin-mpfr-1.c29
-rw-r--r--gcc/testsuite/gcc.dg/torture/builtin-symmetric-1.c111
-rw-r--r--gcc/testsuite/gcc.dg/torture/builtin-wctype-1.c57
-rw-r--r--gcc/testsuite/gcc.dg/torture/calleesave-sse.c43
-rw-r--r--gcc/testsuite/gcc.dg/torture/cris-asm-mof-1.c36
-rw-r--r--gcc/testsuite/gcc.dg/torture/cris-volatile-1.c72
-rw-r--r--gcc/testsuite/gcc.dg/torture/darwin-cfstring-3.c30
-rw-r--r--gcc/testsuite/gcc.dg/torture/dg-torture.exp7
-rw-r--r--gcc/testsuite/gcc.dg/torture/fp-int-convert-double.c18
-rw-r--r--gcc/testsuite/gcc.dg/torture/fp-int-convert-float.c18
-rw-r--r--gcc/testsuite/gcc.dg/torture/fp-int-convert-float128-timode.c15
-rw-r--r--gcc/testsuite/gcc.dg/torture/fp-int-convert-float128.c19
-rw-r--r--gcc/testsuite/gcc.dg/torture/fp-int-convert-float80-timode.c16
-rw-r--r--gcc/testsuite/gcc.dg/torture/fp-int-convert-float80.c19
-rw-r--r--gcc/testsuite/gcc.dg/torture/fp-int-convert-long-double.c18
-rw-r--r--gcc/testsuite/gcc.dg/torture/fp-int-convert-timode.c21
-rw-r--r--gcc/testsuite/gcc.dg/torture/fp-int-convert.h89
-rw-r--r--gcc/testsuite/gcc.dg/torture/inline-1.c16
-rw-r--r--gcc/testsuite/gcc.dg/torture/inline-2.c35
-rw-r--r--gcc/testsuite/gcc.dg/torture/ipa-pta-1.c46
-rw-r--r--gcc/testsuite/gcc.dg/torture/ipa-pta-2.c24
-rw-r--r--gcc/testsuite/gcc.dg/torture/mips-clobber-at.c4
-rw-r--r--gcc/testsuite/gcc.dg/torture/mips-div-1.c9
-rw-r--r--gcc/testsuite/gcc.dg/torture/mips-hilo-2.c27
-rw-r--r--gcc/testsuite/gcc.dg/torture/mips-sdata-1.c10
-rw-r--r--gcc/testsuite/gcc.dg/torture/nested-fn-1.c74
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr16104-1.c79
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr17526.c27
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr17933-1.c14
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr18582-1.c24
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr19462-1.c56
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr19683-1.c42
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr20314-1.c56
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr20314-2.c47
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr21817-1.c16
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr23424-1.c16
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr23821.c29
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr24257.c26
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr24626-1.c27
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr24626-2.c54
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr24626-3.c18
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr24626-4.c12
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr24750-1.c73
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr24912-1.c10
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr25183.c22
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr25481.c18
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr25654.c37
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr25706-1.c35
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr25718-1.c27
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr25947-1.c22
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr26222.c21
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr26258.c28
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr26515.c27
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr26565.c30
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr26587.c29
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr26630.c12
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr26672.c8
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr26763-1.c18
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr26763-2.c18
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr26869.c7
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr26898-1.c15
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr26898-2.c12
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr26998.c11
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr27116-2.c13
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr27116.c15
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr27136.c10
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr27184.c22
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr27302-2.c52
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr27302.c15
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr27409.c17
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr27603.c16
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr27743.c16
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr27773.c6
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr28045.c22
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr28230.c20
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr28268.c8
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr28814.c17
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr28900.c15
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr29119.c7
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr29446.c32
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr29584.c28
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr30313.c23
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr30364-1.c20
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr30364-2.c20
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr30364-3.c21
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr30375.c37
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr30665-1.c24
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr30665-2.c57
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr31115.c22
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr31254.c26
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr32897.c27
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr33560.c29
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr33563.c21
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr33655.c14
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr33848.c43
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr33870.c29
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr34174-1.c44
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr34330.c22
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr35227.c9
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr35400.c22
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr35771-1.c9
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr35771-2.c9
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr35771-3.c9
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr35771.h30
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr35833.c22
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr35842.c12
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr36066.c54
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr36227.c17
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr36244.c40
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr36373-1.c35
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr36373-10.c29
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr36373-2.c37
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr36373-3.c36
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr36373-4.c33
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr36373-5.c34
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr36373-6.c30
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr36373-7.c29
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr36373-8.c24
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr36373-9.c23
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr36400.c16
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr36891.c22
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr36978.c14
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr37731-1.c17
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr37731-2.c17
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr37868.c39
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr37969.c20
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr38271.c18
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr38405.c29
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr38774.c16
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr38948.c101
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr39074-2.c34
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr39074-3.c25
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr39074.c33
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr39132.c34
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr39204.c131
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr39241.c16
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr39678.c27
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr39829.c27
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr39855.c24
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr39903-1.c24
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr39903-2.c24
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr40328.c11
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr40470-1.c22
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr40470-2.c27
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr40470-3.c22
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr40470-4.c29
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr41094.c19
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr41261.c8
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr41555.c119
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr42363.c84
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr42667.c13
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr42878-1.c30
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr42878-2.c34
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr42898-2.c25
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr42898.c23
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr42952.c19
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr43000.c24
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr43002.c16
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr43017.c99
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr43165.c17
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr43360.c20
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr43560.c34
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr43781.c45
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr43879-3.c41
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr43879_1.c27
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr43879_2.c17
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr44050.c21
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr44695.c15
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr44806.c91
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr44807.c40
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr44913.c24
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr44977.c41
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr45017.c24
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr45623.c29
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr45636.c77
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr45678-1.c17
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr45678-2.c17
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr45704.c15
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr45720.c50
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr45732.c10
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr45764.c27
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr45860.c11
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr45865.c54
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr45869.c15
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr45967-2.c24
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr45967-3.c21
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr45967.c21
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr45982.c28
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr46068.c16
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr46172.c13
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr46183.c20
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr46216.c24
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr46398.c24
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr46723.c10
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr47228.c31
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr47278-1.c5
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr47278-2.c15
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr47281.c23
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr47365.c39
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr47370.c27
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr47411.c42
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr47426-1.c23
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr47426-2.c19
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr47473.c14
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr47621.c14
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr47677.c34
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr47743.c22
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr47890.c9
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr47968.c11
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr47975.c10
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr48044.c7
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr48063.c19
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr48098.c12
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr48343.c19
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr48542.c57
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr48702.c47
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr48731.c24
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr48822.c20
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr48953.c17
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr49079.c31
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr49217.c26
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr49518.c19
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr49651.c31
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr49886.c102
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr50092.c15
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr50287.c109
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr50396.c22
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr50472.c12
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr50723.c26
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr51042.c22
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr51070-2.c35
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr51070.c34
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr51071-2.c38
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr51071.c33
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr51106-1.c14
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr51106-2.c14
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr52060.c57
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr52407.c34
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr52693.c33
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr53790.c17
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr53908.c288
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr55755.c43
-rw-r--r--gcc/testsuite/gcc.dg/torture/pta-callused-1.c25
-rw-r--r--gcc/testsuite/gcc.dg/torture/pta-escape-1.c34
-rw-r--r--gcc/testsuite/gcc.dg/torture/pta-ptrarith-1.c33
-rw-r--r--gcc/testsuite/gcc.dg/torture/pta-ptrarith-2.c36
-rw-r--r--gcc/testsuite/gcc.dg/torture/pta-ptrarith-3.c37
-rw-r--r--gcc/testsuite/gcc.dg/torture/pta-structcopy-1.c34
-rw-r--r--gcc/testsuite/gcc.dg/torture/reassoc-1.c24
-rw-r--r--gcc/testsuite/gcc.dg/torture/ssa-pta-fn-1.c62
-rw-r--r--gcc/testsuite/gcc.dg/torture/stackalign/alloca-1.c45
-rw-r--r--gcc/testsuite/gcc.dg/torture/stackalign/alloca-2.c49
-rw-r--r--gcc/testsuite/gcc.dg/torture/stackalign/alloca-3.c49
-rw-r--r--gcc/testsuite/gcc.dg/torture/stackalign/alloca-4.c41
-rw-r--r--gcc/testsuite/gcc.dg/torture/stackalign/alloca-5.c32
-rw-r--r--gcc/testsuite/gcc.dg/torture/stackalign/alloca-6.c34
-rw-r--r--gcc/testsuite/gcc.dg/torture/stackalign/builtin-apply-1.c9
-rw-r--r--gcc/testsuite/gcc.dg/torture/stackalign/builtin-apply-2.c30
-rw-r--r--gcc/testsuite/gcc.dg/torture/stackalign/builtin-apply-3.c31
-rw-r--r--gcc/testsuite/gcc.dg/torture/stackalign/builtin-apply-4.c29
-rw-r--r--gcc/testsuite/gcc.dg/torture/stackalign/builtin-return-1.c34
-rw-r--r--gcc/testsuite/gcc.dg/torture/stackalign/check.h36
-rw-r--r--gcc/testsuite/gcc.dg/torture/stackalign/comp-goto-1.c41
-rw-r--r--gcc/testsuite/gcc.dg/torture/stackalign/fastcall-1.c31
-rw-r--r--gcc/testsuite/gcc.dg/torture/stackalign/global-1.c28
-rw-r--r--gcc/testsuite/gcc.dg/torture/stackalign/inline-1.c29
-rw-r--r--gcc/testsuite/gcc.dg/torture/stackalign/inline-2.c46
-rw-r--r--gcc/testsuite/gcc.dg/torture/stackalign/nested-1.c45
-rw-r--r--gcc/testsuite/gcc.dg/torture/stackalign/nested-2.c46
-rw-r--r--gcc/testsuite/gcc.dg/torture/stackalign/nested-3.c63
-rw-r--r--gcc/testsuite/gcc.dg/torture/stackalign/nested-4.c34
-rw-r--r--gcc/testsuite/gcc.dg/torture/stackalign/nested-5.c38
-rw-r--r--gcc/testsuite/gcc.dg/torture/stackalign/nested-6.c28
-rw-r--r--gcc/testsuite/gcc.dg/torture/stackalign/non-local-goto-1.c55
-rw-r--r--gcc/testsuite/gcc.dg/torture/stackalign/non-local-goto-2.c56
-rw-r--r--gcc/testsuite/gcc.dg/torture/stackalign/non-local-goto-3.c42
-rw-r--r--gcc/testsuite/gcc.dg/torture/stackalign/non-local-goto-4.c38
-rw-r--r--gcc/testsuite/gcc.dg/torture/stackalign/non-local-goto-5.c11
-rw-r--r--gcc/testsuite/gcc.dg/torture/stackalign/pr16660-1.c18
-rw-r--r--gcc/testsuite/gcc.dg/torture/stackalign/pr16660-2.c12
-rw-r--r--gcc/testsuite/gcc.dg/torture/stackalign/pr16660-3.c14
-rw-r--r--gcc/testsuite/gcc.dg/torture/stackalign/push-1.c51
-rw-r--r--gcc/testsuite/gcc.dg/torture/stackalign/regparm-1.c60
-rw-r--r--gcc/testsuite/gcc.dg/torture/stackalign/ret-struct-1.c36
-rw-r--r--gcc/testsuite/gcc.dg/torture/stackalign/setjmp-1.c43
-rw-r--r--gcc/testsuite/gcc.dg/torture/stackalign/setjmp-2.c46
-rw-r--r--gcc/testsuite/gcc.dg/torture/stackalign/setjmp-3.c37
-rw-r--r--gcc/testsuite/gcc.dg/torture/stackalign/setjmp-4.c39
-rw-r--r--gcc/testsuite/gcc.dg/torture/stackalign/sibcall-1.c35
-rw-r--r--gcc/testsuite/gcc.dg/torture/stackalign/stackalign.exp50
-rw-r--r--gcc/testsuite/gcc.dg/torture/stackalign/struct-1.c29
-rw-r--r--gcc/testsuite/gcc.dg/torture/stackalign/thiscall-1.c31
-rw-r--r--gcc/testsuite/gcc.dg/torture/stackalign/vararg-1.c60
-rw-r--r--gcc/testsuite/gcc.dg/torture/stackalign/vararg-2.c66
-rw-r--r--gcc/testsuite/gcc.dg/torture/stackalign/vararg-3.c78
-rw-r--r--gcc/testsuite/gcc.dg/torture/tls/thr-init-1.c26
-rw-r--r--gcc/testsuite/gcc.dg/torture/tls/thr-init-2.c29
-rw-r--r--gcc/testsuite/gcc.dg/torture/tls/tls-test.c52
-rw-r--r--gcc/testsuite/gcc.dg/torture/tls/tls.exp36
-rw-r--r--gcc/testsuite/gcc.dg/torture/tree-loop-1.c21
-rw-r--r--gcc/testsuite/gcc.dg/torture/type-generic-1.c13
-rw-r--r--gcc/testsuite/gcc.dg/torture/va-arg-25.c44
-rw-r--r--gcc/testsuite/gcc.dg/torture/vector-1.c42
-rw-r--r--gcc/testsuite/gcc.dg/torture/vector-2.c52
-rw-r--r--gcc/testsuite/gcc.dg/torture/vector-shift2.c61
353 files changed, 14865 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/torture/20080716-1.c b/gcc/testsuite/gcc.dg/torture/20080716-1.c
new file mode 100644
index 000000000..91fcd2b00
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/20080716-1.c
@@ -0,0 +1,58 @@
+/* { dg-do run } */
+/* { dg-require-effective-target lp64 } */
+
+typedef unsigned long size_t;
+struct tree_base
+{
+ int code;
+};
+struct tree_decl_minimal
+{
+ struct tree_base base;
+ const char *name;
+};
+typedef union tree_node {
+ struct tree_base base;
+ struct tree_decl_minimal decl_minimal;
+} *tree;
+struct tree_overload
+{
+ struct tree_base common;
+ tree function;
+};
+typedef struct VEC_tree_base { unsigned num; unsigned alloc; tree vec[1]; } VEC_tree_base;
+typedef struct VEC_tree_gc { VEC_tree_base base; } VEC_tree_gc;
+static __inline__ unsigned VEC_tree_base_length (const VEC_tree_base *vec_)
+{ return vec_ ? vec_->num : 0; }
+static __inline__ int VEC_tree_base_iterate (const VEC_tree_base *vec_, unsigned ix_, tree *ptr)
+{
+ if (vec_ && ix_ < vec_->num) { *ptr = vec_->vec[ix_]; return 1; } else { *ptr = 0; return 0; }
+}
+extern void abort (void);
+void __attribute__((noinline)) foo (size_t x)
+{
+ if (x != 18446744073709551614UL)
+ abort ();
+}
+void
+resort_type_method_vec (VEC_tree_gc *method_vec)
+{
+ int len = (VEC_tree_base_length(((method_vec) ? &(method_vec)->base : 0)));
+ size_t slot;
+ tree fn;
+
+ for (slot = 2;
+ (VEC_tree_base_iterate(((method_vec) ? &(method_vec)->base : 0),slot,&(fn)));
+ ++slot)
+ if (!(((((((fn)->base.code) == 225) ? (((struct tree_overload*)(fn))->function) : (fn)))->decl_minimal.name)))
+ break;
+
+ if (len - slot > 1)
+ foo (len - slot);
+}
+
+int main ()
+{
+ resort_type_method_vec ((void *)0);
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/20090618-1.c b/gcc/testsuite/gcc.dg/torture/20090618-1.c
new file mode 100644
index 000000000..60eb90078
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/20090618-1.c
@@ -0,0 +1,25 @@
+/* { dg-do run } */
+/* { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */
+/* { dg-skip-if "PR middle-end/47405" { mips-sgi-irix* } } */
+
+extern void abort (void);
+
+struct X { int *p; int *q; };
+
+int foo(void)
+{
+ int i = 0, j = 1;
+ struct X x, y;
+ int **p;
+ y.p = &i;
+ x.q = &j;
+ p = __builtin_mempcpy (&x, &y, sizeof (int *));
+ return **p;
+}
+
+int main()
+{
+ if (foo() != 1)
+ abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/arm-fp16-compile-assign.c b/gcc/testsuite/gcc.dg/torture/arm-fp16-compile-assign.c
new file mode 100644
index 000000000..d6143d278
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/arm-fp16-compile-assign.c
@@ -0,0 +1,29 @@
+/* { dg-do compile { target arm*-*-* } } */
+/* { dg-options "-mfp16-format=ieee" } */
+
+/* Test basic assignments and conversions for __fp16. */
+
+__fp16 h0 = -1.0;
+__fp16 h1 = 0.0;
+__fp16 h2 = 1234.0;
+__fp16 h3 = 42.0;
+float f1 = 2.0;
+float f2 = -999.9;
+
+void f (__fp16 *p)
+{
+ __fp16 t;
+
+ h0 = 1.0;
+ h1 = h2;
+ h2 = f1;
+ f2 = h2;
+
+ t = *p;
+ *p = h3;
+ h3 = t;
+}
+
+/* Make sure we are not falling through to undefined libcalls. */
+/* { dg-final { scan-assembler-not "__truncsfhf" } } */
+/* { dg-final { scan-assembler-not "__extendhfsf" } } */
diff --git a/gcc/testsuite/gcc.dg/torture/arm-fp16-compile-convert.c b/gcc/testsuite/gcc.dg/torture/arm-fp16-compile-convert.c
new file mode 100644
index 000000000..04341959f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/arm-fp16-compile-convert.c
@@ -0,0 +1,41 @@
+/* { dg-do compile { target arm*-*-* } } */
+/* { dg-options "-mfp16-format=ieee" } */
+
+/* Test basic assignments and conversions for __fp16. */
+
+__fp16 h1 = 0.0;
+__fp16 h2 = 1234.0;
+char c1 = 1;
+char c2 = 2;
+short s1 = 10;
+short s2 = 20;
+int i1 = -100;
+int i2 = -200;
+long long l1 = 1000.0;
+long long l2 = 2000.0;
+double d1 = -10000.0;
+double d2 = -20000.0;
+
+void f (void)
+{
+ c1 = h1;
+ h2 = c2;
+
+ h1 = s1;
+ s2 = h2;
+
+ i1 = h1;
+ h2 = i2;
+
+ h1 = l1;
+ l2 = h2;
+
+ d1 = h1;
+ h2 = d2;
+}
+
+/* Make sure we are not falling through to undefined libcalls. */
+/* { dg-final { scan-assembler-not "__float.ihf" } } */
+/* { dg-final { scan-assembler-not "__fixhf.i" } } */
+/* { dg-final { scan-assembler-not "__trunc.fhf" } } */
+/* { dg-final { scan-assembler-not "__extendhf.f" } } */
diff --git a/gcc/testsuite/gcc.dg/torture/arm-fp16-int-convert-alt.c b/gcc/testsuite/gcc.dg/torture/arm-fp16-int-convert-alt.c
new file mode 100644
index 000000000..bcd7aeff1
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/arm-fp16-int-convert-alt.c
@@ -0,0 +1,17 @@
+/* Test floating-point conversions. Standard types and __fp16. */
+/* { dg-do run { target arm*-*-* } } */
+/* { dg-options "-mfp16-format=alternative" } */
+
+#include "fp-int-convert.h"
+#define FP16_MANT_DIG 11
+
+int
+main (void)
+{
+ TEST_I_F(signed char, unsigned char, float, FP16_MANT_DIG);
+ TEST_I_F(signed short, unsigned short, float, FP16_MANT_DIG);
+ TEST_I_F(signed int, unsigned int, float, FP16_MANT_DIG);
+ TEST_I_F(signed long, unsigned long, float, FP16_MANT_DIG);
+ TEST_I_F(signed long long, unsigned long long, float, FP16_MANT_DIG);
+ exit (0);
+}
diff --git a/gcc/testsuite/gcc.dg/torture/arm-fp16-int-convert-ieee.c b/gcc/testsuite/gcc.dg/torture/arm-fp16-int-convert-ieee.c
new file mode 100644
index 000000000..1314d4b0e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/arm-fp16-int-convert-ieee.c
@@ -0,0 +1,17 @@
+/* Test floating-point conversions. Standard types and __fp16. */
+/* { dg-do run { target arm*-*-* } } */
+/* { dg-options "-mfp16-format=ieee" } */
+
+#include "fp-int-convert.h"
+#define FP16_MANT_DIG 11
+
+int
+main (void)
+{
+ TEST_I_F(signed char, unsigned char, float, FP16_MANT_DIG);
+ TEST_I_F(signed short, unsigned short, float, FP16_MANT_DIG);
+ TEST_I_F(signed int, unsigned int, float, FP16_MANT_DIG);
+ TEST_I_F(signed long, unsigned long, float, FP16_MANT_DIG);
+ TEST_I_F(signed long long, unsigned long long, float, FP16_MANT_DIG);
+ exit (0);
+}
diff --git a/gcc/testsuite/gcc.dg/torture/arm-fp16-ops-1.c b/gcc/testsuite/gcc.dg/torture/arm-fp16-ops-1.c
new file mode 100644
index 000000000..0c601e68c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/arm-fp16-ops-1.c
@@ -0,0 +1,5 @@
+/* Test various operators on __fp16 and mixed __fp16/float operands. */
+/* { dg-do run { target arm*-*-* } } */
+/* { dg-options "-mfp16-format=ieee" } */
+
+#include "arm-fp16-ops.h"
diff --git a/gcc/testsuite/gcc.dg/torture/arm-fp16-ops-2.c b/gcc/testsuite/gcc.dg/torture/arm-fp16-ops-2.c
new file mode 100644
index 000000000..244e31082
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/arm-fp16-ops-2.c
@@ -0,0 +1,5 @@
+/* Test various operators on __fp16 and mixed __fp16/float operands. */
+/* { dg-do run { target arm*-*-* } } */
+/* { dg-options "-mfp16-format=ieee -ffast-math" } */
+
+#include "arm-fp16-ops.h"
diff --git a/gcc/testsuite/gcc.dg/torture/arm-fp16-ops-3.c b/gcc/testsuite/gcc.dg/torture/arm-fp16-ops-3.c
new file mode 100644
index 000000000..8f9ab64bc
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/arm-fp16-ops-3.c
@@ -0,0 +1,5 @@
+/* Test various operators on __fp16 and mixed __fp16/float operands. */
+/* { dg-do run { target arm*-*-* } } */
+/* { dg-options "-mfp16-format=alternative" } */
+
+#include "arm-fp16-ops.h"
diff --git a/gcc/testsuite/gcc.dg/torture/arm-fp16-ops-4.c b/gcc/testsuite/gcc.dg/torture/arm-fp16-ops-4.c
new file mode 100644
index 000000000..4877f392c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/arm-fp16-ops-4.c
@@ -0,0 +1,5 @@
+/* Test various operators on __fp16 and mixed __fp16/float operands. */
+/* { dg-do run { target arm*-*-* } } */
+/* { dg-options "-mfp16-format=alternative -ffast-math" } */
+
+#include "arm-fp16-ops.h"
diff --git a/gcc/testsuite/gcc.dg/torture/arm-fp16-ops-5.c b/gcc/testsuite/gcc.dg/torture/arm-fp16-ops-5.c
new file mode 100644
index 000000000..92bc8a9c0
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/arm-fp16-ops-5.c
@@ -0,0 +1,15 @@
+/* Test various operators on __fp16 and mixed __fp16/float operands. */
+/* { dg-do compile { target arm*-*-* } } */
+/* { dg-require-effective-target arm_fp16_ok } */
+/* { dg-options "-mfp16-format=ieee" } */
+/* { dg-add-options arm_fp16 } */
+
+#include "arm-fp16-ops.h"
+
+/* We've specified options for hardware float, including fp16 support, so
+ we should not see any calls to libfuncs here. */
+/* { dg-final { scan-assembler-not "\tbl\t__.*hf2" } } */
+/* { dg-final { scan-assembler-not "\tbl\t__.*hf3" } } */
+/* { dg-final { scan-assembler-not "\tbl\t__gnu_h\[a-z\]*_ieee" } } */
+/* { dg-final { scan-assembler-not "\tbl\t__gnu_h2f_ieee" } } */
+/* { dg-final { scan-assembler-not "\tbl\t__gnu_f2h_ieee" } } */
diff --git a/gcc/testsuite/gcc.dg/torture/arm-fp16-ops-6.c b/gcc/testsuite/gcc.dg/torture/arm-fp16-ops-6.c
new file mode 100644
index 000000000..ae40b1e86
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/arm-fp16-ops-6.c
@@ -0,0 +1,15 @@
+/* Test various operators on __fp16 and mixed __fp16/float operands. */
+/* { dg-do compile { target arm*-*-* } } */
+/* { dg-require-effective-target arm_fp16_ok } */
+/* { dg-options "-mfp16-format=ieee -ffast-math" } */
+/* { dg-add-options arm_fp16 } */
+
+#include "arm-fp16-ops.h"
+
+/* We've specified options for hardware float, including fp16 support, so
+ we should not see any calls to libfuncs here. */
+/* { dg-final { scan-assembler-not "\tbl\t__.*hf2" } } */
+/* { dg-final { scan-assembler-not "\tbl\t__.*hf3" } } */
+/* { dg-final { scan-assembler-not "\tbl\t__gnu_h\[a-z\]*_ieee" } } */
+/* { dg-final { scan-assembler-not "\tbl\t__gnu_h2f_ieee" } } */
+/* { dg-final { scan-assembler-not "\tbl\t__gnu_f2h_ieee" } } */
diff --git a/gcc/testsuite/gcc.dg/torture/arm-fp16-ops-7.c b/gcc/testsuite/gcc.dg/torture/arm-fp16-ops-7.c
new file mode 100644
index 000000000..ed8089bd6
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/arm-fp16-ops-7.c
@@ -0,0 +1,13 @@
+/* Test various operators on __fp16 and mixed __fp16/float operands. */
+/* { dg-do compile { target arm*-*-* } } */
+/* { dg-require-effective-target arm_neon_ok } */
+/* { dg-options "-mfp16-format=ieee" } */
+/* { dg-add-options arm_neon } */
+
+#include "arm-fp16-ops.h"
+
+/* We've specified options for hardware float, so we should not see any
+ calls to libfuncs here except for those to the conversion functions. */
+/* { dg-final { scan-assembler-not "\tbl\t__.*hf2" } } */
+/* { dg-final { scan-assembler-not "\tbl\t__.*hf3" } } */
+/* { dg-final { scan-assembler-not "\tbl\t__gnu_h\[a-z\]*_ieee" } } */
diff --git a/gcc/testsuite/gcc.dg/torture/arm-fp16-ops-8.c b/gcc/testsuite/gcc.dg/torture/arm-fp16-ops-8.c
new file mode 100644
index 000000000..b138ca187
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/arm-fp16-ops-8.c
@@ -0,0 +1,13 @@
+/* Test various operators on __fp16 and mixed __fp16/float operands. */
+/* { dg-do compile { target arm*-*-* } } */
+/* { dg-require-effective-target arm_neon_ok } */
+/* { dg-options "-mfp16-format=ieee -ffast-math" } */
+/* { dg-add-options arm_neon } */
+
+#include "arm-fp16-ops.h"
+
+/* We've specified options for hardware float, so we should not see any
+ calls to libfuncs here except for those to the conversion functions. */
+/* { dg-final { scan-assembler-not "\tbl\t__.*hf2" } } */
+/* { dg-final { scan-assembler-not "\tbl\t__.*hf3" } } */
+/* { dg-final { scan-assembler-not "\tbl\t__gnu_h\[a-z\]*_ieee" } } */
diff --git a/gcc/testsuite/gcc.dg/torture/arm-fp16-ops.h b/gcc/testsuite/gcc.dg/torture/arm-fp16-ops.h
new file mode 100644
index 000000000..320494ee7
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/arm-fp16-ops.h
@@ -0,0 +1,135 @@
+/* Test various operators on __fp16 and mixed __fp16/float operands. */
+
+#include <assert.h>
+
+#define CHECK(e,r) assert ((e) == r)
+#define CHECK2(e,r) (assert ((e) == r), temp = (e), assert (temp == r))
+#define TEST(e) assert (e)
+#define TESTNOT(e) assert (!(e))
+
+volatile __fp16 h0 = 0.0;
+volatile __fp16 h1 = 1.0;
+volatile __fp16 h42 = 42.0;
+volatile __fp16 hm2 = -2.0;
+volatile __fp16 temp;
+
+volatile float f0 = 0.0;
+volatile float f1 = 1.0;
+volatile float f42 = 42.0;
+volatile float fm2 = -2.0;
+
+int main (void)
+{
+ TEST (h1);
+ TESTNOT (h0);
+ TEST (!h0);
+ TESTNOT (!h1);
+
+ CHECK2 (-h1, -1.0);
+ CHECK2 (+h1, 1.0);
+
+ CHECK (h1++, 1.0);
+ CHECK (h1, 2.0);
+ CHECK (++h1, 3.0);
+ CHECK (h1, 3.0);
+
+ CHECK (--h1, 2.0);
+ CHECK (h1, 2.0);
+ CHECK (h1--, 2.0);
+ CHECK (h1, 1.0);
+
+ CHECK2 (h42 * hm2, -84.0);
+ CHECK2 (h42 * (__fp16) -2.0, -84.0);
+ CHECK2 (h42 * fm2, -84.0);
+ CHECK2 (f42 * hm2, -84.0);
+
+ CHECK2 (h42 / hm2, -21.0);
+ CHECK2 (h42 / (__fp16) -2.0, -21.0);
+ CHECK2 (h42 / fm2, -21.0);
+ CHECK2 (f42 / hm2, -21.0);
+
+ CHECK2 (hm2 + h42, 40.0);
+ CHECK2 ((__fp16)-2.0 + h42, 40.0);
+ CHECK2 (hm2 + f42, 40.0);
+ CHECK2 (fm2 + h42, 40.0);
+
+ CHECK2 (hm2 - h42, -44.0);
+ CHECK2 ((__fp16)-2.0 - h42, -44.0);
+ CHECK2 (hm2 - f42, -44.0);
+ CHECK2 (fm2 - h42, -44.0);
+
+ TEST (hm2 < h42);
+ TEST (hm2 < (__fp16)42.0);
+ TEST (hm2 < f42);
+ TEST (fm2 < h42);
+
+ TEST (h42 > hm2);
+ TEST ((__fp16)42.0 > hm2);
+ TEST (h42 > fm2);
+ TEST (f42 > hm2);
+
+ TEST (hm2 <= h42);
+ TEST (hm2 <= (__fp16)42.0);
+ TEST (hm2 <= f42);
+ TEST (fm2 <= h42);
+
+ TEST (h42 >= hm2);
+ TEST (h42 >= (__fp16)-2.0);
+ TEST (h42 >= fm2);
+ TEST (f42 >= hm2);
+
+ TESTNOT (h1 == hm2);
+ TEST (h1 == h1);
+ TEST (h1 == (__fp16)1.0);
+ TEST (h1 == f1);
+ TEST (f1 == h1);
+
+ TEST (h1 != hm2);
+ TESTNOT (h1 != h1);
+ TESTNOT (h1 != (__fp16)1.0);
+ TESTNOT (h1 != f1);
+ TESTNOT (f1 != h1);
+
+ CHECK2 ((h1 ? hm2 : h42), -2.0);
+ CHECK2 ((h0 ? hm2 : h42), 42.0);
+
+ CHECK (h0 = h42, 42.0);
+ CHECK (h0, 42.0);
+ CHECK (h0 = (__fp16)-2.0, -2.0);
+ CHECK (h0, -2.0);
+ CHECK (h0 = f0, 0.0);
+ CHECK (h0, 0.0);
+
+ CHECK (h0 += h1, 1.0);
+ CHECK (h0, 1.0);
+ CHECK (h0 += (__fp16)1.0, 2.0);
+ CHECK (h0, 2.0);
+ CHECK (h0 += fm2, 0.0);
+ CHECK (h0, 0.0);
+
+ CHECK (h0 -= h1, -1.0);
+ CHECK (h0, -1.0);
+ CHECK (h0 -= (__fp16)1.0, -2.0);
+ CHECK (h0, -2.0);
+ CHECK (h0 -= fm2, 0.0);
+ CHECK (h0, 0.0);
+
+ h0 = hm2;
+ CHECK (h0 *= hm2, 4.0);
+ CHECK (h0, 4.0);
+ CHECK (h0 *= (__fp16)-2.0, -8.0);
+ CHECK (h0, -8.0);
+ CHECK (h0 *= fm2, 16.0);
+ CHECK (h0, 16.0);
+
+ CHECK (h0 /= hm2, -8.0);
+ CHECK (h0, -8.0);
+ CHECK (h0 /= (__fp16)-2.0, 4.0);
+ CHECK (h0, 4.0);
+ CHECK (h0 /= fm2, -2.0);
+ CHECK (h0, -2.0);
+
+ CHECK ((h0, h1), 1.0);
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/asm-subreg-1.c b/gcc/testsuite/gcc.dg/torture/asm-subreg-1.c
new file mode 100644
index 000000000..d3a14b24c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/asm-subreg-1.c
@@ -0,0 +1,15 @@
+/* PR middle-end/20491 */
+
+/* { dg-do compile } */
+/* { dg-skip-if "" { hppa*64*-*-* || sparc-*-vxworks* } "*" "" } */
+
+/* Combine used to introduce invalid subregs for the asm input, and
+ we'd crash later on, when removing all subregs. */
+
+volatile unsigned short _const_32 [4] = {1,2,3,4};
+void
+evas_common_convert_yuv_420p_601_rgba()
+{
+ __asm__ __volatile__ ("" : : "X" (*_const_32));
+}
+
diff --git a/gcc/testsuite/gcc.dg/torture/badshift.c b/gcc/testsuite/gcc.dg/torture/badshift.c
new file mode 100644
index 000000000..7288a3745
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/badshift.c
@@ -0,0 +1,29 @@
+/* PR rtl-optimization/20532 */
+
+/* { dg-do run } */
+/* { dg-options "" } */
+/* { dg-options "-march=i386" { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */
+
+/* We used to optimize the DImode shift-by-32 to zero because in combine
+ we turned:
+
+ (v << 31) + (v << 31)
+
+ into:
+
+ (v * (((HOST_WIDE_INT)1 << 31) + ((HOST_WIDE_INT)1 << 31)))
+
+ With a 32-bit HOST_WIDE_INT, the coefficient overflowed to zero. */
+
+unsigned long long int badshift(unsigned long long int v)
+{
+ return v << 31 << 1;
+}
+
+extern void abort ();
+
+int main() {
+ if (badshift (1) == 0)
+ abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/builtin-attr-1.c b/gcc/testsuite/gcc.dg/torture/builtin-attr-1.c
new file mode 100644
index 000000000..bd383a2b3
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/builtin-attr-1.c
@@ -0,0 +1,435 @@
+/* Copyright (C) 2003, 2005 Free Software Foundation.
+
+ Verify that the `const' function attribute is applied to various
+ builtins and that these functions are optimized away by the
+ compiler under the appropriate circumstances.
+
+ Written by Kaveh Ghazi, 2003-08-04. */
+
+/* { dg-do link } */
+/* { dg-options "-ffast-math" } */
+
+/* These are helper macros to test combinations of functions. We test
+ foo() != foo() with the same arguments, and expect the compiler to
+ optimize away these tests of const functions. */
+
+/* Just test the __builtin_ functions. */
+#define BUILTIN_TEST1(FN, TYPE) \
+extern void link_failure_builtin_##FN(void); \
+void test_builtin_##FN(TYPE x) \
+{ if (__builtin_##FN(x) != __builtin_##FN(x)) link_failure_builtin_##FN(); }
+
+/* Just test the __builtin_ functions. */
+#define BUILTIN_TEST2(FN, TYPE) \
+extern void link_failure_builtin_##FN(void); \
+void test_builtin_##FN(TYPE x, TYPE y) \
+{ if (__builtin_##FN(x,y) != __builtin_##FN(x,y)) link_failure_builtin_##FN(); }
+
+/* Also test the regular (non-__builtin_) function. */
+#define TEST1(FN, TYPE, RTYPE) \
+BUILTIN_TEST1(FN, TYPE) \
+extern void link_failure_##FN(void); \
+extern RTYPE FN(TYPE); \
+void test_##FN(TYPE x) { if (FN(x) != FN(x)) link_failure_##FN(); }
+
+/* Test the __builtin_ functions taking void arguments (with the "f"
+ and "l" variants). */
+#define BUILTIN_FPTEST0(FN) \
+extern void link_failure_builtin_##FN(void); \
+extern void link_failure_builtin_##FN##f(void); \
+extern void link_failure_builtin_##FN##l(void); \
+void test_builtin_##FN(void) \
+{ if (__builtin_##FN() != __builtin_##FN()) link_failure_builtin_##FN(); } \
+void test_builtin_##FN##f(void) \
+{ if (__builtin_##FN##f() != __builtin_##FN##f()) link_failure_builtin_##FN##f(); } \
+void test_builtin_##FN##l(void) \
+{ if (__builtin_##FN##l() != __builtin_##FN##l()) link_failure_builtin_##FN##l(); }
+
+/* Test the __builtin_ functions taking one FP argument (with the "f"
+ and "l" variants). */
+#define BUILTIN_FPTEST1(FN) \
+extern void link_failure_builtin_##FN(void); \
+extern void link_failure_builtin_##FN##f(void); \
+extern void link_failure_builtin_##FN##l(void); \
+void test_builtin_##FN(double d) \
+{ if (__builtin_##FN(d) != __builtin_##FN(d)) link_failure_builtin_##FN(); } \
+void test_builtin_##FN##f(float f) \
+{ if (__builtin_##FN##f(f) != __builtin_##FN##f(f)) link_failure_builtin_##FN##f(); } \
+void test_builtin_##FN##l(long double ld) \
+{ if (__builtin_##FN##l(ld) != __builtin_##FN##l(ld)) link_failure_builtin_##FN##l(); }
+
+/* Test the __builtin_ functions taking one argument of supplied type
+ (with the "f" and "l" variants). */
+#define BUILTIN_FPTEST1ARG(FN, TYPE) \
+extern void link_failure_builtin_##FN(void); \
+extern void link_failure_builtin_##FN##f(void); \
+extern void link_failure_builtin_##FN##l(void); \
+void test_builtin_##FN(TYPE x) \
+{ if (__builtin_##FN(x) != __builtin_##FN(x)) link_failure_builtin_##FN(); } \
+void test_builtin_##FN##f(TYPE x) \
+{ if (__builtin_##FN##f(x) != __builtin_##FN##f(x)) link_failure_builtin_##FN##f(); } \
+void test_builtin_##FN##l(TYPE x) \
+{ if (__builtin_##FN##l(x) != __builtin_##FN##l(x)) link_failure_builtin_##FN##l(); }
+
+/* Test the __builtin_ functions taking two FP arguments (with the "f"
+ and "l" variants). */
+#define BUILTIN_FPTEST2(FN) \
+extern void link_failure_builtin_##FN(void); \
+extern void link_failure_builtin_##FN##f(void); \
+extern void link_failure_builtin_##FN##l(void); \
+void test_builtin_##FN(double d1, double d2) \
+{ if (__builtin_##FN(d1,d2) != __builtin_##FN(d1,d2)) link_failure_builtin_##FN(); } \
+void test_builtin_##FN##f(float f1, float f2) \
+{ if (__builtin_##FN##f(f1,f2) != __builtin_##FN##f(f1,f2)) link_failure_builtin_##FN##f(); } \
+void test_builtin_##FN##l(long double ld1, long double ld2) \
+{ if (__builtin_##FN##l(ld1,ld2) != __builtin_##FN##l(ld1,ld2)) link_failure_builtin_##FN##l(); }
+
+/* Test the __builtin_ functions taking two arguments, the first one
+ is of a supplied type and the second one one is of FP type (with
+ the "f" and "l" variants). */
+#define BUILTIN_FPTEST2ARG1(FN, TYPE) \
+extern void link_failure_builtin_##FN(void); \
+extern void link_failure_builtin_##FN##f(void); \
+extern void link_failure_builtin_##FN##l(void); \
+void test_builtin_##FN(TYPE x, double d) \
+{ if (__builtin_##FN(x,d) != __builtin_##FN(x,d)) link_failure_builtin_##FN(); } \
+void test_builtin_##FN##f(TYPE x, float f) \
+{ if (__builtin_##FN##f(x,f) != __builtin_##FN##f(x,f)) link_failure_builtin_##FN##f(); } \
+void test_builtin_##FN##l(TYPE x, long double ld) \
+{ if (__builtin_##FN##l(x,ld) != __builtin_##FN##l(x,ld)) link_failure_builtin_##FN##l(); }
+
+/* Test the __builtin_ functions taking two arguments, the first one
+ is of FP type and the second one one is of a supplied type (with
+ the "f" and "l" variants). */
+#define BUILTIN_FPTEST2ARG2(FN, TYPE) \
+extern void link_failure_builtin_##FN(void); \
+extern void link_failure_builtin_##FN##f(void); \
+extern void link_failure_builtin_##FN##l(void); \
+void test_builtin_##FN(double d, TYPE x) \
+{ if (__builtin_##FN(d,x) != __builtin_##FN(d,x)) link_failure_builtin_##FN(); } \
+void test_builtin_##FN##f(float f, TYPE x) \
+{ if (__builtin_##FN##f(f,x) != __builtin_##FN##f(f,x)) link_failure_builtin_##FN##f(); } \
+void test_builtin_##FN##l(long double ld, TYPE x) \
+{ if (__builtin_##FN##l(ld,x) != __builtin_##FN##l(ld,x)) link_failure_builtin_##FN##l(); }
+
+/* Test the __builtin_ functions taking three FP arguments (with the
+ "f" and "l" variants). */
+#define BUILTIN_FPTEST3(FN) \
+extern void link_failure_builtin_##FN(void); \
+extern void link_failure_builtin_##FN##f(void); \
+extern void link_failure_builtin_##FN##l(void); \
+void test_builtin_##FN(double d1, double d2, double d3) \
+{ if (__builtin_##FN(d1,d2,d3) != __builtin_##FN(d1,d2,d3)) link_failure_builtin_##FN(); } \
+void test_builtin_##FN##f(float f1, float f2, float f3) \
+{ if (__builtin_##FN##f(f1,f2,f3) != __builtin_##FN##f(f1,f2,f3)) link_failure_builtin_##FN##f(); } \
+void test_builtin_##FN##l(long double ld1, long double ld2, long double ld3) \
+{ if (__builtin_##FN##l(ld1,ld2,ld3) != __builtin_##FN##l(ld1,ld2,ld3)) link_failure_builtin_##FN##l(); }
+
+/* Test the __builtin_ functions taking one complex argument (with the
+ "f" and "l" variants). */
+#define BUILTIN_CPTEST1(FN) \
+extern void link_failure_builtin_##FN(void); \
+extern void link_failure_builtin_##FN##f(void); \
+extern void link_failure_builtin_##FN##l(void); \
+void test_builtin_##FN(_Complex double d) \
+{ if (__builtin_##FN(d) != __builtin_##FN(d)) link_failure_builtin_##FN(); } \
+void test_builtin_##FN##f(_Complex float f) \
+{ if (__builtin_##FN##f(f) != __builtin_##FN##f(f)) link_failure_builtin_##FN##f(); } \
+void test_builtin_##FN##l(_Complex long double ld) \
+{ if (__builtin_##FN##l(ld) != __builtin_##FN##l(ld)) link_failure_builtin_##FN##l(); }
+
+/* Test the __builtin_ functions taking two complex arguments (with
+ the "f" and "l" variants). */
+#define BUILTIN_CPTEST2(FN) \
+extern void link_failure_builtin_##FN(void); \
+extern void link_failure_builtin_##FN##f(void); \
+extern void link_failure_builtin_##FN##l(void); \
+void test_builtin_##FN(_Complex double d1, _Complex double d2) \
+{ if (__builtin_##FN(d1,d2) != __builtin_##FN(d1,d2)) link_failure_builtin_##FN(); } \
+void test_builtin_##FN##f(_Complex float f1, _Complex float f2) \
+{ if (__builtin_##FN##f(f1,f2) != __builtin_##FN##f(f1,f2)) link_failure_builtin_##FN##f(); } \
+void test_builtin_##FN##l(_Complex long double ld1, _Complex long double ld2) \
+{ if (__builtin_##FN##l(ld1,ld2) != __builtin_##FN##l(ld1,ld2)) link_failure_builtin_##FN##l(); }
+
+/* These macros additionally test the non-__builtin_ functions. */
+
+/* Test the functions taking one FP argument (with the "f" and "l"
+ variants) and returning that type. */
+#define FPTEST1(FN) \
+BUILTIN_FPTEST1(FN) \
+extern void link_failure_##FN(void); \
+extern void link_failure_##FN##f(void); \
+extern void link_failure_##FN##l(void); \
+extern double FN(double); \
+extern float FN##f(float); \
+extern long double FN##l(long double); \
+void test_##FN(double d) \
+{ if (FN(d) != FN(d)) link_failure_##FN(); } \
+void test_##FN##f(float f) \
+{ if (FN##f(f) != FN##f(f)) link_failure_##FN##f(); } \
+void test_##FN##l(long double ld) \
+{ if (FN##l(ld) != FN##l(ld)) link_failure_##FN##l(); }
+
+/* Test the functions taking one FP argument (with the "f" and "l"
+ variants) and returning TYPE. */
+#define FPTEST1T(FN, TYPE) \
+BUILTIN_FPTEST1(FN) \
+extern void link_failure_##FN(void); \
+extern void link_failure_##FN##f(void); \
+extern void link_failure_##FN##l(void); \
+extern TYPE FN(double); \
+extern TYPE FN##f(float); \
+extern TYPE FN##l(long double); \
+void test_##FN(double d) \
+{ if (FN(d) != FN(d)) link_failure_##FN(); } \
+void test_##FN##f(float f) \
+{ if (FN##f(f) != FN##f(f)) link_failure_##FN##f(); } \
+void test_##FN##l(long double ld) \
+{ if (FN##l(ld) != FN##l(ld)) link_failure_##FN##l(); }
+
+/* Test the functions taking two FP arguments (with the "f" and "l"
+ variants). */
+#define FPTEST2(FN) \
+BUILTIN_FPTEST2(FN) \
+extern void link_failure_##FN(void); \
+extern void link_failure_##FN##f(void); \
+extern void link_failure_##FN##l(void); \
+extern double FN(double, double); \
+extern float FN##f(float, float); \
+extern long double FN##l(long double, long double); \
+void test_##FN(double d1, double d2) \
+{ if (FN(d1,d2) != FN(d1,d2)) link_failure_##FN(); } \
+void test_##FN##f(float f1, float f2) \
+{ if (FN##f(f1,f2) != FN##f(f1,f2)) link_failure_##FN##f(); } \
+void test_##FN##l(long double ld1, long double ld2) \
+{ if (FN##l(ld1,ld2) != FN##l(ld1,ld2)) link_failure_##FN##l(); }
+
+/* Test the functions taking two arguments, the first one is of a
+ supplied type and the second one one is of FP type (with the "f"
+ and "l" variants). */
+#define FPTEST2ARG1(FN, TYPE) \
+BUILTIN_FPTEST2ARG1(FN, TYPE) \
+extern void link_failure_##FN(void); \
+extern void link_failure_##FN##f(void); \
+extern void link_failure_##FN##l(void); \
+extern double FN(TYPE, double); \
+extern float FN##f(TYPE, float); \
+extern long double FN##l(TYPE, long double); \
+void test_##FN(TYPE x, double d) \
+{ if (FN(x,d) != FN(x,d)) link_failure_##FN(); } \
+void test_##FN##f(TYPE x, float f) \
+{ if (FN##f(x,f) != FN##f(x,f)) link_failure_##FN##f(); } \
+void test_##FN##l(TYPE x, long double ld) \
+{ if (FN##l(x,ld) != FN##l(x,ld)) link_failure_##FN##l(); }
+
+/* Test the functions taking two arguments, the first one is of FP
+ type and the second one one is of a supplied type (with the "f" and
+ "l" variants). */
+#define FPTEST2ARG2(FN, TYPE) \
+BUILTIN_FPTEST2ARG2(FN, TYPE) \
+extern void link_failure_##FN(void); \
+extern void link_failure_##FN##f(void); \
+extern void link_failure_##FN##l(void); \
+extern double FN(double, TYPE); \
+extern float FN##f(float, TYPE); \
+extern long double FN##l(long double, TYPE); \
+void test_##FN(double d, TYPE x) \
+{ if (FN(d,x) != FN(d,x)) link_failure_##FN(); } \
+void test_##FN##f(float f, TYPE x) \
+{ if (FN##f(f,x) != FN##f(f,x)) link_failure_##FN##f(); } \
+void test_##FN##l(long double ld, TYPE x) \
+{ if (FN##l(ld,x) != FN##l(ld,x)) link_failure_##FN##l(); }
+
+/* Test the functions taking three FP arguments (with the "f" and "l"
+ variants). */
+#define FPTEST3(FN) \
+BUILTIN_FPTEST3(FN) \
+extern void link_failure_##FN(void); \
+extern void link_failure_##FN##f(void); \
+extern void link_failure_##FN##l(void); \
+extern double FN(double, double, double); \
+extern float FN##f(float, float, float); \
+extern long double FN##l(long double, long double, long double); \
+void test_##FN(double d1, double d2, double d3) \
+{ if (FN(d1,d2,d3) != FN(d1,d2,d3)) link_failure_##FN(); } \
+void test_##FN##f(float f1, float f2, float f3) \
+{ if (FN##f(f1,f2,f3) != FN##f(f1,f2,f3)) link_failure_##FN##f(); } \
+void test_##FN##l(long double ld1, long double ld2, long double ld3) \
+{ if (FN##l(ld1,ld2,ld3) != FN##l(ld1,ld2,ld3)) link_failure_##FN##l(); }
+
+/* Test the functions taking one complex argument (with the "f" and
+ "l" variants) and returning that type. */
+#define CPTEST1(FN) \
+BUILTIN_CPTEST1(FN) \
+extern void link_failure_##FN(void); \
+extern void link_failure_##FN##f(void); \
+extern void link_failure_##FN##l(void); \
+extern _Complex double FN(_Complex double); \
+extern _Complex float FN##f(_Complex float); \
+extern _Complex long double FN##l(_Complex long double); \
+void test_##FN(_Complex double d) \
+{ if (FN(d) != FN(d)) link_failure_##FN(); } \
+void test_##FN##f(_Complex float f) \
+{ if (FN##f(f) != FN##f(f)) link_failure_##FN##f(); } \
+void test_##FN##l(_Complex long double ld) \
+{ if (FN##l(ld) != FN##l(ld)) link_failure_##FN##l(); }
+
+/* Test the functions taking one complex argument (with the "f" and
+ "l" variants) and returning the real type. */
+#define CPTEST1R(FN) \
+BUILTIN_CPTEST1(FN) \
+extern void link_failure_##FN(void); \
+extern void link_failure_##FN##f(void); \
+extern void link_failure_##FN##l(void); \
+extern double FN(_Complex double); \
+extern float FN##f(_Complex float); \
+extern long double FN##l(_Complex long double); \
+void test_##FN(_Complex double d) \
+{ if (FN(d) != FN(d)) link_failure_##FN(); } \
+void test_##FN##f(_Complex float f) \
+{ if (FN##f(f) != FN##f(f)) link_failure_##FN##f(); } \
+void test_##FN##l(_Complex long double ld) \
+{ if (FN##l(ld) != FN##l(ld)) link_failure_##FN##l(); }
+
+/* Test the functions taking two complex arguments (with the "f" and
+ "l" variants). */
+#define CPTEST2(FN) \
+BUILTIN_CPTEST2(FN) \
+extern void link_failure_##FN(void); \
+extern void link_failure_##FN##f(void); \
+extern void link_failure_##FN##l(void); \
+extern _Complex double FN(_Complex double, _Complex double); \
+extern _Complex float FN##f(_Complex float, _Complex float); \
+extern _Complex long double FN##l(_Complex long double, _Complex long double); \
+void test_##FN(_Complex double d1, _Complex double d2) \
+{ if (FN(d1,d2) != FN(d1,d2)) link_failure_##FN(); } \
+void test_##FN##f(_Complex float f1, _Complex float f2) \
+{ if (FN##f(f1,f2) != FN##f(f1,f2)) link_failure_##FN##f(); } \
+void test_##FN##l(_Complex long double ld1, _Complex long double ld2) \
+{ if (FN##l(ld1,ld2) != FN##l(ld1,ld2)) link_failure_##FN##l(); }
+
+
+/* Test the math builtins. */
+FPTEST1 (acos)
+FPTEST1 (acosh)
+FPTEST1 (asin)
+FPTEST1 (asinh)
+FPTEST1 (atan)
+FPTEST2 (atan2)
+FPTEST1 (atanh)
+FPTEST1 (cbrt)
+FPTEST1 (ceil)
+FPTEST2 (copysign)
+FPTEST1 (cos)
+FPTEST1 (cosh)
+FPTEST2 (drem)
+FPTEST1 (erf)
+FPTEST1 (erfc)
+FPTEST1 (exp)
+FPTEST1 (exp10)
+FPTEST1 (exp2)
+FPTEST1 (expm1)
+FPTEST1 (fabs)
+FPTEST2 (fdim)
+FPTEST1 (floor)
+FPTEST3 (fma)
+FPTEST2 (fmax)
+FPTEST2 (fmin)
+FPTEST2 (fmod)
+BUILTIN_FPTEST0 (huge_val)
+FPTEST2 (hypot)
+FPTEST1T (ilogb, int)
+BUILTIN_FPTEST0 (inf) /* { dg-warning "does not support infinity" "INF unsupported" { target vax-*-* pdp11-*-* spu-*-* } } */
+FPTEST1 (j0)
+FPTEST1 (j1)
+FPTEST2ARG1 (jn, int)
+FPTEST2ARG2 (ldexp, int)
+BUILTIN_FPTEST1 (llceil)
+BUILTIN_FPTEST1 (llfloor)
+FPTEST1T (llrint, long long)
+FPTEST1T (llround, long long)
+FPTEST1 (log)
+FPTEST1 (log10)
+FPTEST1 (log1p)
+FPTEST1 (log2)
+FPTEST1 (logb)
+BUILTIN_FPTEST1 (lceil)
+BUILTIN_FPTEST1 (lfloor)
+FPTEST1T (lrint, long)
+FPTEST1T (lround, long)
+BUILTIN_FPTEST1ARG (nan, char *)
+BUILTIN_FPTEST1ARG (nans, char *)
+FPTEST1 (nearbyint)
+FPTEST2 (nextafter)
+FPTEST2ARG2 (nexttoward, long double)
+FPTEST2 (pow)
+FPTEST1 (pow10)
+FPTEST2 (remainder)
+FPTEST1 (rint)
+FPTEST1 (round)
+FPTEST2 (scalb)
+FPTEST2ARG2 (scalbn, int)
+FPTEST2ARG2 (scalbln, long int)
+FPTEST1 (significand)
+FPTEST1 (sin)
+FPTEST1 (sinh)
+FPTEST1 (sqrt)
+FPTEST1 (tan)
+FPTEST1 (tanh)
+FPTEST1 (tgamma)
+FPTEST1 (trunc)
+FPTEST1 (y0)
+FPTEST1 (y1)
+FPTEST2ARG1 (yn, int)
+
+/* Test the complex math builtins. */
+/*CPTEST1 (cabs) See http://gcc.gnu.org/ml/gcc-patches/2003-09/msg00040.html */
+CPTEST1 (cacos)
+CPTEST1 (cacosh)
+CPTEST1R (carg)
+CPTEST1 (casin)
+CPTEST1 (casinh)
+CPTEST1 (catan)
+CPTEST1 (catanh)
+CPTEST1 (ccos)
+CPTEST1 (ccosh)
+CPTEST1 (cexp)
+CPTEST1R (cimag)
+CPTEST1 (clog)
+CPTEST1 (conj)
+CPTEST2 (cpow)
+CPTEST1 (cproj)
+CPTEST1R (creal)
+CPTEST1 (csin)
+CPTEST1 (csinh)
+CPTEST1 (csqrt)
+CPTEST1 (ctan)
+CPTEST1 (ctanh)
+
+typedef __INTMAX_TYPE__ intmax_t;
+
+/* Various other const builtins. */
+TEST1 (abs, int, int)
+BUILTIN_TEST1 (clz, int)
+BUILTIN_TEST1 (clzl, long)
+BUILTIN_TEST1 (clzll, long long)
+BUILTIN_TEST1 (ctz, int)
+BUILTIN_TEST1 (ctzl, long)
+BUILTIN_TEST1 (ctzll, long long)
+TEST1 (ffs, int, int)
+TEST1 (ffsl, long, int)
+TEST1 (ffsll, long long, int)
+TEST1 (imaxabs, intmax_t, intmax_t)
+TEST1 (labs, long, long)
+TEST1 (llabs, long long, long long)
+BUILTIN_TEST1 (parity, int)
+BUILTIN_TEST1 (parityl, long)
+BUILTIN_TEST1 (parityll, long long)
+BUILTIN_TEST1 (popcount, int)
+BUILTIN_TEST1 (popcountl, long)
+BUILTIN_TEST1 (popcountll, long long)
+
+int main(void)
+{
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/builtin-convert-1.c b/gcc/testsuite/gcc.dg/torture/builtin-convert-1.c
new file mode 100644
index 000000000..f13d29e67
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/builtin-convert-1.c
@@ -0,0 +1,149 @@
+/* Copyright (C) 2004 Free Software Foundation.
+
+ Verify that built-in math function conversion to smaller FP types
+ is correctly performed by the compiler.
+
+ Written by Kaveh Ghazi, 2004-03-17. */
+
+/* { dg-do link } */
+/* { dg-options "-ffast-math" } */
+/* { dg-add-options c99_runtime } */
+
+#include "../builtins-config.h"
+
+/* This check is necessary when converting to a C99 function. */
+#ifdef HAVE_C99_RUNTIME
+#define C99CODE(CODE) (CODE)
+#define MAYBEC99(CODE, C99) (CODE)
+#else
+#define C99CODE(CODE) 0
+#define MAYBEC99(CODE, C99) (!(C99) && (CODE))
+#endif
+
+void test(double d1, float f1, long double ld1)
+{
+ /* Test converting math builtins to narrower FP types based on a
+ narrowing cast on the outside of the call. MATHFN is the
+ function to test, and C99 is 0/1 depending on whether the
+ `double' version of MATHFN is a C99 function. The optimization
+ is only performed if the replacement function is actually
+ narrower in width, so check that first. */
+#define OUTER_CAST1(MATHFN, C99) \
+ extern void link_failure_outer_##MATHFN##l_##MATHFN##_1(void); \
+ extern void link_failure_outer_##MATHFN##l_##MATHFN##_2(void); \
+ extern void link_failure_outer_##MATHFN##l_##MATHFN##f_1(void); \
+ extern void link_failure_outer_##MATHFN##l_##MATHFN##f_2(void); \
+ extern void link_failure_outer_##MATHFN##_##MATHFN##f_1(void); \
+ extern void link_failure_outer_##MATHFN##_##MATHFN##f_2(void); \
+ if (sizeof (long double) > sizeof (double) \
+ && MAYBEC99 ((double) __builtin_##MATHFN##l((double)ld1) != __builtin_##MATHFN(ld1), C99)) \
+ link_failure_outer_##MATHFN##l_##MATHFN##_1(); \
+ if (sizeof (long double) > sizeof (double) \
+ && MAYBEC99 ((double) __builtin_##MATHFN##l(d1) != __builtin_##MATHFN(d1), C99)) \
+ link_failure_outer_##MATHFN##l_##MATHFN##_1(); \
+ if (sizeof (long double) > sizeof (double) \
+ && MAYBEC99 ((double) __builtin_##MATHFN##l(f1) != __builtin_##MATHFN(f1), C99)) \
+ link_failure_outer_##MATHFN##l_##MATHFN##_2(); \
+ if (sizeof (long double) > sizeof (float) \
+ && C99CODE ((float) __builtin_##MATHFN##l((float) ld1) != __builtin_##MATHFN##f(ld1))) \
+ link_failure_outer_##MATHFN##l_##MATHFN##f_1(); \
+ if (sizeof (long double) > sizeof (float) \
+ && C99CODE ((float) __builtin_##MATHFN##l((float) d1) != __builtin_##MATHFN##f(d1))) \
+ link_failure_outer_##MATHFN##l_##MATHFN##f_1(); \
+ if (sizeof (long double) > sizeof (float) \
+ && C99CODE ((float) __builtin_##MATHFN##l(f1) != __builtin_##MATHFN##f(f1))) \
+ link_failure_outer_##MATHFN##l_##MATHFN##f_2(); \
+ if (sizeof (double) > sizeof (float) \
+ && C99CODE ((float) __builtin_##MATHFN((float) ld1) != __builtin_##MATHFN##f(ld1))) \
+ link_failure_outer_##MATHFN##_##MATHFN##f_1(); \
+ if (sizeof (double) > sizeof (float) \
+ && C99CODE ((float) __builtin_##MATHFN((float) d1) != __builtin_##MATHFN##f(d1))) \
+ link_failure_outer_##MATHFN##_##MATHFN##f_1(); \
+ if (sizeof (double) > sizeof (float) \
+ && C99CODE ((float) __builtin_##MATHFN(f1) != __builtin_##MATHFN##f(f1))) \
+ link_failure_outer_##MATHFN##_##MATHFN##f_2()
+
+ /* Test converting math builtins to narrower FP types based on if
+ the argument is a narrower type (perhaps implicitly) cast to a
+ wider one. */
+#define INNER_CAST1(MATHFN, C99) \
+ extern void link_failure_inner_##MATHFN##l_##MATHFN(void); \
+ extern void link_failure_inner_##MATHFN##l_##MATHFN##f(void); \
+ extern void link_failure_inner_##MATHFN##_##MATHFN##f(void); \
+ if (sizeof (long double) > sizeof (double) \
+ && MAYBEC99 (__builtin_##MATHFN##l(d1) != (long double) __builtin_##MATHFN(d1), C99)) \
+ link_failure_inner_##MATHFN##l_##MATHFN(); \
+ if (sizeof (long double) > sizeof (float) \
+ && C99CODE (__builtin_##MATHFN##l(f1) != (long double) __builtin_##MATHFN##f(f1))) \
+ link_failure_inner_##MATHFN##l_##MATHFN##f(); \
+ if (sizeof (long double) > sizeof (float) \
+ && C99CODE (__builtin_##MATHFN##l((double)f1) != (long double) __builtin_##MATHFN##f(f1))) \
+ link_failure_inner_##MATHFN##l_##MATHFN##f(); \
+ if (sizeof (double) > sizeof (float) \
+ && C99CODE (__builtin_##MATHFN(f1) != (double) __builtin_##MATHFN##f(f1))) \
+ link_failure_inner_##MATHFN##_##MATHFN##f()
+
+
+#ifdef __OPTIMIZE__
+ OUTER_CAST1 (acos, /*C99=*/ 0);
+ OUTER_CAST1 (acosh, /*C99=*/ 1);
+ OUTER_CAST1 (asin, /*C99=*/ 1);
+ OUTER_CAST1 (asinh, /*C99=*/ 1);
+ OUTER_CAST1 (atan, /*C99=*/ 0);
+ OUTER_CAST1 (atanh, /*C99=*/ 1);
+ OUTER_CAST1 (cbrt, /*C99=*/ 1);
+ OUTER_CAST1 (cos, /*C99=*/ 0);
+ OUTER_CAST1 (cosh, /*C99=*/ 0);
+ OUTER_CAST1 (erf, /*C99=*/ 1);
+ OUTER_CAST1 (erfc, /*C99=*/ 1);
+ OUTER_CAST1 (exp, /*C99=*/ 0);
+ OUTER_CAST1 (exp2, /*C99=*/ 1);
+ OUTER_CAST1 (expm1, /*C99=*/ 1);
+ OUTER_CAST1 (fabs, /*C99=*/ 0);
+ OUTER_CAST1 (log, /*C99=*/ 0);
+ OUTER_CAST1 (log10, /*C99=*/ 0);
+ OUTER_CAST1 (log1p, /*C99=*/ 1);
+ OUTER_CAST1 (log2, /*C99=*/ 1);
+ OUTER_CAST1 (logb, /*C99=*/ 1);
+ OUTER_CAST1 (sin, /*C99=*/ 0);
+ OUTER_CAST1 (sinh, /*C99=*/ 0);
+ OUTER_CAST1 (sqrt, /*C99=*/ 0);
+ OUTER_CAST1 (tan, /*C99=*/ 0);
+ OUTER_CAST1 (tanh, /*C99=*/ 0);
+ OUTER_CAST1 (tgamma, /*C99=*/ 1);
+
+ INNER_CAST1 (ceil, /*C99=*/ 0);
+ OUTER_CAST1 (ceil, /*C99=*/ 0);
+ INNER_CAST1 (floor, /*C99=*/ 0);
+ OUTER_CAST1 (floor, /*C99=*/ 0);
+ INNER_CAST1 (lceil, /*C99=*/ 1);
+ OUTER_CAST1 (lceil, /*C99=*/ 1);
+ INNER_CAST1 (lfloor, /*C99=*/ 1);
+ OUTER_CAST1 (lfloor, /*C99=*/ 1);
+ INNER_CAST1 (lrint, /*C99=*/ 1);
+ OUTER_CAST1 (lrint, /*C99=*/ 1);
+ INNER_CAST1 (lround, /*C99=*/ 1);
+ OUTER_CAST1 (lround, /*C99=*/ 1);
+ INNER_CAST1 (llceil, /*C99=*/ 1);
+ OUTER_CAST1 (llceil, /*C99=*/ 1);
+ INNER_CAST1 (llfloor, /*C99=*/ 1);
+ OUTER_CAST1 (llfloor, /*C99=*/ 1);
+ INNER_CAST1 (llrint, /*C99=*/ 1);
+ OUTER_CAST1 (llrint, /*C99=*/ 1);
+ INNER_CAST1 (llround, /*C99=*/ 1);
+ OUTER_CAST1 (llround, /*C99=*/ 1);
+ INNER_CAST1 (nearbyint, /*C99=*/ 1);
+ OUTER_CAST1 (nearbyint, /*C99=*/ 1);
+ INNER_CAST1 (rint, /*C99=*/ 1);
+ OUTER_CAST1 (rint, /*C99=*/ 1);
+ INNER_CAST1 (round, /*C99=*/ 1);
+ OUTER_CAST1 (round, /*C99=*/ 1);
+ INNER_CAST1 (trunc, /*C99=*/ 1);
+ OUTER_CAST1 (trunc, /*C99=*/ 1);
+#endif /* __OPTIMIZE__ */
+}
+
+int main (void)
+{
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/builtin-convert-2.c b/gcc/testsuite/gcc.dg/torture/builtin-convert-2.c
new file mode 100644
index 000000000..167ecddcb
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/builtin-convert-2.c
@@ -0,0 +1,78 @@
+/* Copyright (C) 2004 Free Software Foundation.
+
+ Verify that built-in math function conversion into integer rounding
+ functions is correctly performed by the compiler.
+
+ Written by Kaveh ghazi, 2004-04-26. */
+
+/* { dg-do link } */
+/* { dg-options "-ffast-math" } */
+/* { dg-add-options c99_runtime } */
+
+#include "../builtins-config.h"
+
+/* Macro to do all FP type combinations. The second half tests
+ narrowing the FP type. */
+#define TEST_FP2FIXED(FN1, FN2) \
+ extern void link_error_##FN1##_##FN2(void); \
+ extern void link_error_##FN1##f_##FN2##f(void); \
+ extern void link_error_##FN1##l_##FN2##l(void); \
+ extern void link_error_##FN1##_l##FN2(void); \
+ extern void link_error_##FN1##f_l##FN2##f(void); \
+ extern void link_error_##FN1##l_l##FN2##l(void); \
+ if ((long)__builtin_##FN1(d) != __builtin_##FN2(d)) \
+ link_error_##FN1##_##FN2(); \
+ if ((long)__builtin_##FN1##f(f) != __builtin_##FN2##f(f)) \
+ link_error_##FN1##f_##FN2##f(); \
+ if ((long)__builtin_##FN1##l(ld) != __builtin_##FN2##l(ld)) \
+ link_error_##FN1##l_##FN2##l(); \
+ if ((long long)__builtin_##FN1(d) != __builtin_l##FN2(d)) \
+ link_error_##FN1##_l##FN2(); \
+ if ((long long)__builtin_##FN1##f(f) != __builtin_l##FN2##f(f)) \
+ link_error_##FN1##f_l##FN2##f(); \
+ if ((long long)__builtin_##FN1##l(ld) != __builtin_l##FN2##l(ld)) \
+ link_error_##FN1##l_l##FN2##l(); \
+ extern void link_error_##FN1##_##FN2##f(void); \
+ extern void link_error_##FN1##l_##FN2(void); \
+ extern void link_error_##FN1##l_##FN2##f(void); \
+ extern void link_error_##FN1##_l##FN2##f(void); \
+ extern void link_error_##FN1##l_l##FN2(void); \
+ extern void link_error_##FN1##l_l##FN2##f(void); \
+ if (sizeof(double) > sizeof(float) \
+ && (long)__builtin_##FN1(f) != __builtin_##FN2##f(f)) \
+ link_error_##FN1##_##FN2##f(); \
+ if (sizeof(long double) > sizeof(double) \
+ && (long)__builtin_##FN1##l(d) != __builtin_##FN2(d)) \
+ link_error_##FN1##l_##FN2(); \
+ if (sizeof(long double) > sizeof(float) \
+ && (long)__builtin_##FN1##l(f) != __builtin_##FN2##f(f)) \
+ link_error_##FN1##l_##FN2##f(); \
+ if (sizeof(double) > sizeof(float) \
+ && (long long)__builtin_##FN1(f) != __builtin_l##FN2##f(f)) \
+ link_error_##FN1##_l##FN2##f(); \
+ if (sizeof(long double) > sizeof(double) \
+ && (long long)__builtin_##FN1##l(d) != __builtin_l##FN2(d)) \
+ link_error_##FN1##l_l##FN2(); \
+ if (sizeof(long double) > sizeof(float) \
+ && (long long)__builtin_##FN1##l(f) != __builtin_l##FN2##f(f)) \
+ link_error_##FN1##l_l##FN2##f()
+
+void __attribute__ ((__noinline__)) foo (double d, float f, long double ld)
+{
+#ifdef __OPTIMIZE__
+# ifdef HAVE_C99_RUNTIME
+ /* The resulting transformation functions are all C99. */
+ TEST_FP2FIXED (ceil, lceil);
+ TEST_FP2FIXED (floor, lfloor);
+ TEST_FP2FIXED (round, lround);
+ TEST_FP2FIXED (nearbyint, lrint);
+ TEST_FP2FIXED (rint, lrint);
+# endif
+#endif
+}
+
+int main()
+{
+ foo (1.0, 2.0, 3.0);
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/builtin-convert-3.c b/gcc/testsuite/gcc.dg/torture/builtin-convert-3.c
new file mode 100644
index 000000000..2034b4190
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/builtin-convert-3.c
@@ -0,0 +1,61 @@
+/* Copyright (C) 2004 Free Software Foundation.
+
+ Verify that builtin math functions (with fixed point return types)
+ are converted to smaller FP types correctly by the compiler.
+
+ Written by Kaveh Ghazi, 2004-05-01. */
+
+/* { dg-do link } */
+/* { dg-options "-ffast-math" } */
+/* { dg-add-options c99_runtime } */
+
+#include "../builtins-config.h"
+
+#define PROTOTYPE1_RET(FN, RET) \
+ extern RET FN(double); \
+ extern RET FN##f(float); \
+ extern RET FN##l(long double);
+
+/* Test converting math builtins to narrower FP types based on if the
+ argument is a narrower type (perhaps implicitly) cast to a wider
+ one. */
+#define INNER_CAST1(MATHFN, RET) \
+ PROTOTYPE1_RET (MATHFN, RET); \
+ extern void link_failure_inner_##MATHFN##l_##MATHFN(void); \
+ extern void link_failure_inner_##MATHFN##l_##MATHFN##f(void); \
+ extern void link_failure_inner_##MATHFN##_##MATHFN##f(void); \
+ if (sizeof (long double) > sizeof (double) \
+ && MATHFN##l(d1) != MATHFN(d1)) \
+ link_failure_inner_##MATHFN##l_##MATHFN(); \
+ if (sizeof (long double) > sizeof (float) \
+ && MATHFN##l(f1) != MATHFN##f(f1)) \
+ link_failure_inner_##MATHFN##l_##MATHFN##f(); \
+ if (sizeof (long double) > sizeof (float) \
+ && MATHFN##l((double)f1) != MATHFN##f(f1)) \
+ link_failure_inner_##MATHFN##l_##MATHFN##f(); \
+ if (sizeof (double) > sizeof (float) \
+ && MATHFN(f1) != MATHFN##f(f1)) \
+ link_failure_inner_##MATHFN##_##MATHFN##f()
+
+void __attribute__ ((__noinline__)) test (double d1, float f1)
+{
+#ifdef __OPTIMIZE__
+#ifdef HAVE_C99_RUNTIME
+ /* We're converting to implicitly generated C99 functions. */
+ INNER_CAST1 (__builtin_lceil, long);
+ INNER_CAST1 (__builtin_llceil, long long);
+ INNER_CAST1 (__builtin_lfloor, long);
+ INNER_CAST1 (__builtin_llfloor, long long);
+ INNER_CAST1 (lround, long);
+ INNER_CAST1 (llround, long long);
+ INNER_CAST1 (lrint, long);
+ INNER_CAST1 (llrint, long long);
+#endif /* HAVE_C99_RUNTIME */
+#endif /* __OPTIMIZE__ */
+}
+
+int main (void)
+{
+ test (1, 2);
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/builtin-convert-4.c b/gcc/testsuite/gcc.dg/torture/builtin-convert-4.c
new file mode 100644
index 000000000..3dc47ad1e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/builtin-convert-4.c
@@ -0,0 +1,36 @@
+/* Copyright (C) 2007 Free Software Foundation.
+
+ Verify that nearbyint isn't transformed into e.g. rint or lrint
+ when -ftrapping-math is set.
+
+ Written by Kaveh ghazi, 2007-03-04. */
+
+/* { dg-do compile } */
+/* { dg-options "-ftrapping-math -fdump-tree-original" } */
+/* { dg-add-options c99_runtime } */
+
+#include "../builtins-config.h"
+
+extern void bar (long);
+
+#define TESTIT(FUNC) do { \
+ bar (__builtin_##FUNC(d)); \
+ bar (__builtin_##FUNC##f(f)); \
+ bar (__builtin_##FUNC##l(ld)); \
+} while (0)
+
+void __attribute__ ((__noinline__)) foo (double d, float f, long double ld)
+{
+ TESTIT(nearbyint);
+}
+
+int main()
+{
+ foo (1.0, 2.0, 3.0);
+ return 0;
+}
+
+/* { dg-final { scan-tree-dump-times "nearbyint " 1 "original" } } */
+/* { dg-final { scan-tree-dump-times "nearbyintf" 1 "original" } } */
+/* { dg-final { scan-tree-dump-times "nearbyintl" 1 "original" } } */
+/* { dg-final { cleanup-tree-dump "original" } } */
diff --git a/gcc/testsuite/gcc.dg/torture/builtin-cproj-1.c b/gcc/testsuite/gcc.dg/torture/builtin-cproj-1.c
new file mode 100644
index 000000000..53ae6046a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/builtin-cproj-1.c
@@ -0,0 +1,247 @@
+/* Copyright (C) 2010 Free Software Foundation.
+
+ Verify that folding of built-in cproj is correctly performed by the
+ compiler.
+
+ Origin: Kaveh R. Ghazi, April 9, 2010. */
+
+/* { dg-do link } */
+/* { dg-add-options ieee } */
+
+/* All references to link_error should go away at compile-time. The
+ argument is the __LINE__ number. It appears in the tree dump file
+ and aids in debugging should any of the tests fail. */
+extern void link_error(int);
+
+#define CPROJ(X) __builtin_cproj(X)
+#define CPROJF(X) __builtin_cprojf(X)
+#define CPROJL(X) __builtin_cprojl(X)
+#ifndef __SPU__
+#define INF __builtin_inff()
+#else
+#define INF __builtin_inf()
+#endif
+#define I 1i
+#define CPSGN(X,Y) __builtin_copysignf((X),(Y))
+#define CIMAG(X) __builtin_cimagf(X)
+#define CREAL(X) __builtin_crealf(X)
+
+/* Check that the signs of the real and/or imaginary parts of two
+ complex numbers match. */
+#define CKSGN(X,Y) (CKSGN_R(X,Y) || CKSGN_I(X,Y))
+#define CKSGN_R(X,Y) (CPSGN(1,CREAL(X)) != CPSGN(1,CREAL(Y)))
+#define CKSGN_I(X,Y) (CPSGN(1,CIMAG(X)) != CPSGN(1,CIMAG(Y)))
+
+/* Test that (cproj(X) == ZERO+Inf) and that the signs of the
+ imaginary parts match. ZERO is +/- 0i. */
+#ifndef __SPU__
+#define TEST_CST_INF(X,ZERO) do { \
+ if (CPROJF(X) != ZERO+INF || CKSGN_I(CPROJF(X),ZERO+INF)) \
+ link_error(__LINE__); \
+ if (CPROJ(X) != ZERO+INF || CKSGN_I(CPROJ(X),ZERO+INF)) \
+ link_error(__LINE__); \
+ if (CPROJL(X) != ZERO+INF || CKSGN_I(CPROJL(X),ZERO+INF)) \
+ link_error(__LINE__); \
+} while (0)
+#else
+#define TEST_CST_INF(X,ZERO) do { \
+ if (CPROJ(X) != ZERO+INF || CKSGN_I(CPROJ(X),ZERO+INF)) \
+ link_error(__LINE__); \
+ if (CPROJL(X) != ZERO+INF || CKSGN_I(CPROJL(X),ZERO+INF)) \
+ link_error(__LINE__); \
+} while (0)
+#endif
+
+/* Test that (cproj(X) == X) for all finite (X). */
+#define TEST_CST(X) do { \
+ if (CPROJF(X) != (X) || CKSGN(CPROJF(X),(X))) \
+ link_error(__LINE__); \
+} while (0)
+
+/* Test that cproj(X + I*INF) -> (ZERO + INF), where ZERO is +-0i.
+ NEG is either blank or a minus sign when ZERO is negative. */
+#ifndef __SPU__
+#define TEST_IMAG_INF(NEG,ZERO) do { \
+ if (CPROJF(f+I*NEG INF) != ZERO+INF \
+ || CKSGN_I (CPROJF(f+I*NEG INF), ZERO+INF)) \
+ link_error(__LINE__); \
+ if (CPROJ(d+I*NEG INF) != ZERO+INF \
+ || CKSGN_I (CPROJ(d+I*NEG INF), ZERO+INF)) \
+ link_error(__LINE__); \
+ if (CPROJL(ld+I*NEG INF) != ZERO+INF \
+ || CKSGN_I (CPROJL(ld+I*NEG INF), ZERO+INF)) \
+ link_error(__LINE__); \
+} while (0)
+#else
+#define TEST_IMAG_INF(NEG,ZERO) do { \
+ if (CPROJ(d+I*NEG INF) != ZERO+INF \
+ || CKSGN_I (CPROJ(d+I*NEG INF), ZERO+INF)) \
+ link_error(__LINE__); \
+ if (CPROJL(ld+I*NEG INF) != ZERO+INF \
+ || CKSGN_I (CPROJL(ld+I*NEG INF), ZERO+INF)) \
+ link_error(__LINE__); \
+} while (0)
+#endif
+
+/* Like TEST_IMAG_INF, but check that side effects are honored. */
+#ifndef __SPU__
+#define TEST_IMAG_INF_SIDE_EFFECT(NEG,ZERO) do { \
+ int side = 4; \
+ if (CPROJF(++side+I*NEG INF) != ZERO+INF \
+ || CKSGN_I (CPROJF(++side+I*NEG INF), ZERO+INF)) \
+ link_error(__LINE__); \
+ if (CPROJ(++side+I*NEG INF) != ZERO+INF \
+ || CKSGN_I (CPROJ(++side+I*NEG INF), ZERO+INF)) \
+ link_error(__LINE__); \
+ if (CPROJL(++side+I*NEG INF) != ZERO+INF \
+ || CKSGN_I (CPROJL(++side+I*NEG INF), ZERO+INF)) \
+ link_error(__LINE__); \
+ if (side != 10) \
+ link_error(__LINE__); \
+} while (0)
+#else
+#define TEST_IMAG_INF_SIDE_EFFECT(NEG,ZERO) do { \
+ int side = 4; \
+ if (CPROJ(++side+I*NEG INF) != ZERO+INF \
+ || CKSGN_I (CPROJ(++side+I*NEG INF), ZERO+INF)) \
+ link_error(__LINE__); \
+ if (CPROJL(++side+I*NEG INF) != ZERO+INF \
+ || CKSGN_I (CPROJL(++side+I*NEG INF), ZERO+INF)) \
+ link_error(__LINE__); \
+ if (side != 8) \
+ link_error(__LINE__); \
+} while (0)
+#endif
+
+/* Test that cproj(INF, POSITIVE) -> INF+0i. NEG is either blank or a
+ minus sign to test negative INF. */
+#ifndef __SPU__
+#define TEST_REAL_INF(NEG) do { \
+ __real cf = NEG INF; \
+ __imag cf = (x ? 4 : 5); \
+ if (CPROJF(cf) != INF \
+ || CKSGN_I (CPROJF(cf), INF)) \
+ link_error(__LINE__); \
+ __real cd = NEG INF; \
+ __imag cd = (x ? 4 : 5); \
+ if (CPROJ(cd) != INF \
+ || CKSGN_I (CPROJ(cd), INF)) \
+ link_error(__LINE__); \
+ __real cld = NEG INF; \
+ __imag cld = (x ? 4 : 5); \
+ if (CPROJL(cld) != INF \
+ || CKSGN_I (CPROJL(cld), INF)) \
+ link_error(__LINE__); \
+} while (0)
+#else
+#define TEST_REAL_INF(NEG) do { \
+ __real cd = NEG INF; \
+ __imag cd = (x ? 4 : 5); \
+ if (CPROJ(cd) != INF \
+ || CKSGN_I (CPROJ(cd), INF)) \
+ link_error(__LINE__); \
+ __real cld = NEG INF; \
+ __imag cld = (x ? 4 : 5); \
+ if (CPROJL(cld) != INF \
+ || CKSGN_I (CPROJL(cld), INF)) \
+ link_error(__LINE__); \
+} while (0)
+#endif
+
+/* Like TEST_REAL_INF, but check that side effects are honored. */
+#ifndef __SPU__
+#define TEST_REAL_INF_SIDE_EFFECT(NEG) do { \
+ int side = -9; \
+ __real cf = NEG INF; \
+ __imag cf = (x ? 4 : 5); \
+ if (CPROJF((++side,cf)) != INF \
+ || CKSGN_I (CPROJF((++side,cf)), INF)) \
+ link_error(__LINE__); \
+ __real cd = NEG INF; \
+ __imag cd = (x ? 4 : 5); \
+ if (CPROJ((++side,cd)) != INF \
+ || CKSGN_I (CPROJ((++side,cd)), INF)) \
+ link_error(__LINE__); \
+ __real cld = NEG INF; \
+ __imag cld = (x ? 4 : 5); \
+ if (CPROJL((++side,cld)) != INF \
+ || CKSGN_I (CPROJL((++side,cld)), INF)) \
+ link_error(__LINE__); \
+ if (side != -3) \
+ link_error(__LINE__); \
+} while (0)
+#else
+#define TEST_REAL_INF_SIDE_EFFECT(NEG) do { \
+ int side = -9; \
+ __real cd = NEG INF; \
+ __imag cd = (x ? 4 : 5); \
+ if (CPROJ((++side,cd)) != INF \
+ || CKSGN_I (CPROJ((++side,cd)), INF)) \
+ link_error(__LINE__); \
+ __real cld = NEG INF; \
+ __imag cld = (x ? 4 : 5); \
+ if (CPROJL((++side,cld)) != INF \
+ || CKSGN_I (CPROJL((++side,cld)), INF)) \
+ link_error(__LINE__); \
+ if (side != -5) \
+ link_error(__LINE__); \
+} while (0)
+#endif
+
+void foo (_Complex long double cld, _Complex double cd, _Complex float cf,
+ long double ld, double d, float f, int x)
+{
+ TEST_CST_INF (INF+0I, 0);
+ TEST_CST_INF (INF-0I, -0.FI);
+ TEST_CST_INF (INF+4I, 0);
+ TEST_CST_INF (INF-4I, -0.FI);
+ TEST_CST_INF (-INF+0I, 0);
+ TEST_CST_INF (-INF-0I, -0.FI);
+ TEST_CST_INF (-INF+4I, 0);
+ TEST_CST_INF (-INF-4I, -0.FI);
+
+ TEST_CST_INF (0+I*INF, 0);
+ TEST_CST_INF (0-I*INF, -0.FI);
+ TEST_CST_INF (23+I*INF, 0);
+ TEST_CST_INF (23-I*INF, -0.FI);
+ TEST_CST_INF (-0.F+I*INF, 0);
+ TEST_CST_INF (-0.F-I*INF, -0.FI);
+ TEST_CST_INF (-23+I*INF, 0);
+ TEST_CST_INF (-23-I*INF, -0.FI);
+
+ TEST_CST_INF (INF+I*INF, 0);
+ TEST_CST_INF (INF-I*INF, -0.FI);
+ TEST_CST_INF (-INF+I*INF, 0);
+ TEST_CST_INF (-INF-I*INF, -0.FI);
+
+ TEST_CST (0);
+ TEST_CST (-0.F);
+ TEST_CST (0-0.FI);
+ TEST_CST (-0.F-0.FI);
+
+ TEST_CST (22+3I);
+ TEST_CST (22-3I);
+ TEST_CST (-22+3I);
+ TEST_CST (-22-3I);
+
+ TEST_IMAG_INF (,0.FI);
+ TEST_IMAG_INF (-,-0.FI);
+
+#ifdef __OPTIMIZE__
+ TEST_REAL_INF( );
+ TEST_REAL_INF(-);
+
+ TEST_IMAG_INF_SIDE_EFFECT (,0.FI);
+ TEST_IMAG_INF_SIDE_EFFECT (-,-0.FI);
+
+ TEST_REAL_INF_SIDE_EFFECT( );
+ TEST_REAL_INF_SIDE_EFFECT(-);
+#endif
+
+ return;
+}
+
+int main (void)
+{
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/builtin-cproj-2.c b/gcc/testsuite/gcc.dg/torture/builtin-cproj-2.c
new file mode 100644
index 000000000..39331651f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/builtin-cproj-2.c
@@ -0,0 +1,46 @@
+/* Copyright (C) 2010 Free Software Foundation.
+
+ Verify that folding of built-in cproj is correctly performed by the
+ compiler. With -ffinite-math-only all cproj calls should be
+ eliminated regardless of what the argument is, or what is known
+ about it.
+
+ Origin: Kaveh R. Ghazi, April 9, 2010. */
+
+/* { dg-do link } */
+/* { dg-options "-ffinite-math-only" } */
+
+/* All references to link_error should go away at compile-time. The
+ argument is the __LINE__ number. It appears in the tree dump file
+ and aids in debugging should any of the tests fail. */
+extern void link_error(int);
+
+#define CPROJ(X) __builtin_cproj(X)
+#define CPROJF(X) __builtin_cprojf(X)
+#define CPROJL(X) __builtin_cprojl(X)
+
+/* Test that the supplied expressions eliminte the cproj call. */
+#define TEST_EXPRS(LD_EXPR, D_EXPR, F_EXPR) do { \
+ if (CPROJF(F_EXPR) != (F_EXPR)) \
+ link_error (__LINE__); \
+ if (CPROJ(D_EXPR) != (D_EXPR)) \
+ link_error (__LINE__); \
+ if (CPROJL(LD_EXPR) != (LD_EXPR)) \
+ link_error (__LINE__); \
+} while (0)
+
+void foo (_Complex long double cld, _Complex double cd, _Complex float cf)
+{
+#ifdef __OPTIMIZE__
+ TEST_EXPRS (cld, cd, cf);
+ TEST_EXPRS (cld*2, cd*2, cf*2);
+ TEST_EXPRS (cld*cld, cd*cd, cf*cf);
+#endif
+
+ return;
+}
+
+int main (void)
+{
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/builtin-ctype-1.c b/gcc/testsuite/gcc.dg/torture/builtin-ctype-1.c
new file mode 100644
index 000000000..ad6fc1c60
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/builtin-ctype-1.c
@@ -0,0 +1,44 @@
+/* Copyright (C) 2004 Free Software Foundation.
+
+ Verify that built-in ctype function attributes are correctly set by
+ the compiler.
+
+ Written by Kaveh Ghazi, 2004-03-23. */
+
+/* { dg-do link } */
+
+
+void test(int i)
+{
+ /* All of these ctype functions should be const/pure and thus
+ eliminated. */
+#define TEST_CTYPE(FN) \
+ extern int FN(int); \
+ extern void link_failure_##FN(void); \
+ if (FN(i) != FN(i)) \
+ link_failure_##FN()
+
+#ifdef __OPTIMIZE__
+ TEST_CTYPE(isalnum);
+ TEST_CTYPE(isalpha);
+ TEST_CTYPE(isascii);
+ TEST_CTYPE(isblank);
+ TEST_CTYPE(iscntrl);
+ TEST_CTYPE(isdigit);
+ TEST_CTYPE(isgraph);
+ TEST_CTYPE(islower);
+ TEST_CTYPE(isprint);
+ TEST_CTYPE(ispunct);
+ TEST_CTYPE(isspace);
+ TEST_CTYPE(isupper);
+ TEST_CTYPE(isxdigit);
+ TEST_CTYPE(toascii);
+ TEST_CTYPE(tolower);
+ TEST_CTYPE(toupper);
+#endif /* __OPTIMIZE__ */
+}
+
+int main (void)
+{
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/builtin-ctype-2.c b/gcc/testsuite/gcc.dg/torture/builtin-ctype-2.c
new file mode 100644
index 000000000..7046aad65
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/builtin-ctype-2.c
@@ -0,0 +1,107 @@
+/* Copyright (C) 2004 Free Software Foundation.
+
+ Verify that built-in ctype transformations are done correctly by
+ the compiler.
+
+ Written by Kaveh Ghazi, 2004-04-05. */
+
+/* { dg-do link } */
+
+extern void link_failure_var(void);
+
+void test(int i)
+{
+ /* All of these ctype calls should compile-time evaluate to true. */
+#define TEST_CTYPE_CST_TRUE(FN, VALUE) \
+ extern void link_failure_##FN##_cst_true(void); \
+ extern int FN(int); \
+ if (! FN(VALUE)) \
+ link_failure_##FN##_cst_true()
+
+ /* All of these ctype calls should compile-time evaluate to false. */
+#define TEST_CTYPE_CST_FALSE(FN, VALUE) \
+ extern void link_failure_##FN##_cst_false(void); \
+ extern int FN(int); \
+ if (FN(VALUE)) \
+ link_failure_##FN##_cst_false()
+
+ /* All of these ctype calls should compile-time evaluate to true. */
+#define TEST_TOCTYPE_CST_TRUE(FN, VALUE) \
+ extern void link_failure_##FN##_cst_true(void); \
+ extern int FN(int); \
+ if (FN(VALUE) != (VALUE)) \
+ link_failure_##FN##_cst_true()
+
+ /* All of these ctype calls should compile-time evaluate to false. */
+#define TEST_TOCTYPE_CST_FALSE(FN, VALUE) \
+ extern void link_failure_##FN##_cst_false(void); \
+ extern int FN(int); \
+ if (FN(VALUE) == (VALUE)) \
+ link_failure_##FN##_cst_false()
+
+#ifdef __OPTIMIZE__
+ TEST_CTYPE_CST_TRUE (isascii, 0);
+ TEST_CTYPE_CST_TRUE (isascii, 1);
+ TEST_CTYPE_CST_TRUE (isascii, 126);
+ TEST_CTYPE_CST_TRUE (isascii, 127);
+
+ TEST_CTYPE_CST_FALSE (isascii, -1);
+ TEST_CTYPE_CST_FALSE (isascii, 128);
+ TEST_CTYPE_CST_FALSE (isascii, 129);
+ TEST_CTYPE_CST_FALSE (isascii, 255);
+ TEST_CTYPE_CST_FALSE (isascii, 256);
+ TEST_CTYPE_CST_FALSE (isascii, 257);
+ TEST_CTYPE_CST_FALSE (isascii, 10000);
+ TEST_CTYPE_CST_FALSE (isascii, __INT_MAX__);
+
+ /* This ctype call should transform into another expression. */
+ if (isascii(i) != ((i & ~0x7f) == 0))
+ link_failure_var();
+
+ TEST_TOCTYPE_CST_TRUE (toascii, 0);
+ TEST_TOCTYPE_CST_TRUE (toascii, 1);
+ TEST_TOCTYPE_CST_TRUE (toascii, 126);
+ TEST_TOCTYPE_CST_TRUE (toascii, 127);
+
+ TEST_TOCTYPE_CST_FALSE (toascii, -1);
+ TEST_TOCTYPE_CST_FALSE (toascii, 128);
+ TEST_TOCTYPE_CST_FALSE (toascii, 129);
+ TEST_TOCTYPE_CST_FALSE (toascii, 255);
+ TEST_TOCTYPE_CST_FALSE (toascii, 256);
+ TEST_TOCTYPE_CST_FALSE (toascii, 10000);
+ TEST_TOCTYPE_CST_FALSE (toascii, __INT_MAX__);
+
+ /* This ctype call should transform into another expression. */
+ if (toascii(i) != (i & 0x7f))
+ link_failure_var();
+
+ TEST_CTYPE_CST_TRUE (isdigit, '0');
+ TEST_CTYPE_CST_TRUE (isdigit, '1');
+ TEST_CTYPE_CST_TRUE (isdigit, '2');
+ TEST_CTYPE_CST_TRUE (isdigit, '3');
+ TEST_CTYPE_CST_TRUE (isdigit, '4');
+ TEST_CTYPE_CST_TRUE (isdigit, '5');
+ TEST_CTYPE_CST_TRUE (isdigit, '6');
+ TEST_CTYPE_CST_TRUE (isdigit, '7');
+ TEST_CTYPE_CST_TRUE (isdigit, '8');
+ TEST_CTYPE_CST_TRUE (isdigit, '9');
+
+ TEST_CTYPE_CST_FALSE (isdigit, '0'-1);
+ TEST_CTYPE_CST_FALSE (isdigit, '9'+1);
+ TEST_CTYPE_CST_FALSE (isdigit, -1);
+ TEST_CTYPE_CST_FALSE (isdigit, 0);
+ TEST_CTYPE_CST_FALSE (isdigit, 255);
+ TEST_CTYPE_CST_FALSE (isdigit, 256);
+ TEST_CTYPE_CST_FALSE (isdigit, 10000);
+ TEST_CTYPE_CST_FALSE (isdigit, __INT_MAX__);
+
+ /* This ctype call should transform into another expression. */
+ if (isdigit(i) != ((unsigned)i - '0' <= 9))
+ link_failure_var();
+#endif /* __OPTIMIZE__ */
+}
+
+int main (void)
+{
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/builtin-explog-1.c b/gcc/testsuite/gcc.dg/torture/builtin-explog-1.c
new file mode 100644
index 000000000..740206153
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/builtin-explog-1.c
@@ -0,0 +1,231 @@
+/* Copyright (C) 2003, 2004 Free Software Foundation.
+
+ Verify that built-in math function constant folding of log & exp is
+ correctly performed by the compiler.
+
+ Written by Kaveh Ghazi, 2003-09-05. */
+
+/* { dg-do link } */
+/* { dg-options "-ffast-math" } */
+
+/* Define "e" with as many bits as found in builtins.c:dconste. */
+#define M_E 2.7182818284590452353602874713526624977572470936999595749669676277241
+#define M_EF 2.7182818284590452353602874713526624977572470936999595749669676277241F
+#define M_EL 2.7182818284590452353602874713526624977572470936999595749669676277241L
+/* Precision for comparison tests. */
+#define PREC (sizeof (float) < sizeof (double) ? 0.0000001 : PRECF)
+#define PRECF 0.0001F
+#define PRECL (sizeof (float) < sizeof (long double) \
+ ? 0.0000000000001L : PRECF)
+#define PROTOTYPE(FN) extern double FN(double); extern float FN##f(float); \
+ extern long double FN##l(long double);
+#define PROTOTYPE2(FN) extern double FN(double, double); \
+ extern float FN##f(float, float); \
+ extern long double FN##l(long double, long double);
+
+PROTOTYPE(exp)
+PROTOTYPE(exp2)
+PROTOTYPE(exp10)
+PROTOTYPE(log)
+PROTOTYPE(log2)
+PROTOTYPE(log10)
+PROTOTYPE(pow10)
+PROTOTYPE(sqrt)
+PROTOTYPE(cbrt)
+PROTOTYPE2(pow)
+
+void test(double d1, double d2, float f1, float f2,
+ long double ld1, long double ld2)
+{
+ /* Test logN(1) -> 0. */
+#define LOG_1(LOG) \
+ extern void link_failure_##LOG##_1(void); \
+ if (LOG(1.0) != 0.0 || LOG##f(1.0F) != 0.0F || LOG##l(1.0L) != 0.0L) \
+ link_failure_##LOG##_1()
+
+ LOG_1(log);
+ LOG_1(log2);
+ LOG_1(log10);
+
+ /* Test logN(N) -> 1. */
+#define LOG_N(LOG, BASE) \
+ extern void link_failure_##LOG##_N(void); \
+ if (LOG(BASE) != 1.0 || LOG##f(BASE##F) != 1.0F || LOG##l(BASE##L) != 1.0L) \
+ link_failure_##LOG##_N()
+
+ LOG_N(log2, 2.0);
+ LOG_N(log10, 10.0);
+
+ /* Test logN(expN(x)) -> x. */
+#define LOGEXP_SAME(LOG, EXP) \
+ extern void link_failure_##LOG##_##EXP##_same(void); \
+ if (LOG(EXP(d1)) != d1 || LOG##f(EXP##f(f1)) != f1 \
+ || LOG##l(EXP##l(ld1)) != ld1) link_failure_##LOG##_##EXP##_same()
+
+ LOGEXP_SAME(log,exp);
+ LOGEXP_SAME(log2,exp2);
+ LOGEXP_SAME(log10,exp10);
+ LOGEXP_SAME(log10,pow10);
+
+ /* Test logN(expM(x)) -> x*logN(M). */
+#define LOGEXP(LOG, EXP, BASE) \
+ extern void link_failure_##LOG##_##EXP(void); \
+ if (LOG(EXP(d1)) != d1*LOG(BASE) || LOG##f(EXP##f(f1)) != f1*LOG##f(BASE##F) \
+ || LOG##l(EXP##l(ld1)) != ld1*LOG##l(BASE##L)) link_failure_##LOG##_##EXP()
+
+ LOGEXP(log,exp2,2.0);
+ LOGEXP(log,exp10,10.0);
+ LOGEXP(log,pow10,10.0);
+ LOGEXP(log2,exp,M_E);
+ LOGEXP(log2,exp2,2.0);
+ LOGEXP(log2,exp10,10.0);
+ LOGEXP(log2,pow10,10.0);
+ LOGEXP(log10,exp,M_E);
+ LOGEXP(log10,exp2,2.0);
+ LOGEXP(log10,exp10,10.0);
+ LOGEXP(log10,pow10,10.0);
+
+ /* Test logN(sqrt(x)) -> 0.5*logN(x). */
+#define LOG_SQRT(LOG) \
+ extern void link_failure_##LOG##_sqrt(void); \
+ if (LOG(sqrt(d1)) != 0.5*LOG(d1) || LOG##f(sqrtf(f1)) != 0.5F*LOG##f(f1) \
+ || LOG##l(sqrtl(ld1)) != 0.5L*LOG##l(ld1)) link_failure_##LOG##_sqrt()
+
+ LOG_SQRT(log);
+ LOG_SQRT(log2);
+ LOG_SQRT(log10);
+
+ /* Test sqrt(expN(x)) -> expN(x*0.5). */
+#define SQRT_EXP(EXP) \
+ extern void link_failure_sqrt_##EXP(void); \
+ if (sqrt(EXP(d1)) != EXP(d1*0.5) || sqrtf(EXP##f(f1)) != EXP##f(f1*0.5F) \
+ || sqrtl(EXP##l(ld1)) != EXP##l(ld1*0.5L)) link_failure_sqrt_##EXP()
+
+ SQRT_EXP(exp);
+ SQRT_EXP(exp2);
+ SQRT_EXP(exp10);
+ SQRT_EXP(pow10);
+
+ /* Test logN(cbrt(x)) -> (1/3)*logN(x). */
+#define LOG_CBRT(LOG) \
+ extern void link_failure_##LOG##_cbrt(void); \
+ if (LOG(cbrt(d1)) != (1.0/3)*LOG(d1) \
+ || LOG##f(cbrtf(f1)) != (1.0F/3)*LOG##f(f1) \
+ || LOG##l(cbrtl(ld1)) != (1.0L/3)*LOG##l(ld1)) link_failure_##LOG##_cbrt()
+
+ LOG_CBRT(log);
+ LOG_CBRT(log2);
+ LOG_CBRT(log10);
+
+ /* Test cbrt(expN(x)) -> expN(x/3). */
+#define CBRT_EXP(EXP) \
+ extern void link_failure_cbrt_##EXP(void); \
+ if (cbrt(EXP(d1)) != EXP(d1/3.0) || cbrtf(EXP##f(f1)) != EXP##f(f1/3.0F) \
+ || cbrtl(EXP##l(ld1)) != EXP##l(ld1/3.0L)) link_failure_cbrt_##EXP()
+
+ CBRT_EXP(exp);
+ CBRT_EXP(exp2);
+ CBRT_EXP(exp10);
+ CBRT_EXP(pow10);
+
+ /* Test logN(pow(x,y)) -> y*logN(x). */
+#define LOG_POW(LOG, POW) \
+ extern void link_failure_##LOG##_##POW(void); \
+ if (LOG(POW(d1,d2)) != d2*LOG(d1) || LOG##f(POW##f(f1,f2)) != f2*LOG##f(f1) \
+ || LOG##l(POW##l(ld1,ld2)) != ld2*LOG##l(ld1)) link_failure_##LOG##_##POW()
+
+ LOG_POW(log,pow);
+ LOG_POW(log2,pow);
+ LOG_POW(log10,pow);
+
+ /* Test pow(expN(x),y)) -> expN(x*y). */
+#define POW_EXP(POW, EXP) \
+ extern void link_failure_##POW##_##EXP(void); \
+ if (POW(EXP(d1),d2) != EXP(d1*d2) || POW##f(EXP##f(f1),f2) != EXP##f(f1*f2) \
+ || POW##l(EXP##l(ld1),ld2) != EXP##l(ld1*ld2)) link_failure_##POW##_##EXP()
+
+ POW_EXP(pow, exp);
+ POW_EXP(pow, exp2);
+ POW_EXP(pow, exp10);
+ POW_EXP(pow, pow10);
+
+ /* Test expN(0) -> 1. */
+#define EXP_0(EXP) \
+ extern void link_failure_##EXP##_0(void); \
+ if (EXP(0.0) != 1.0 || EXP##f(0.0F) != 1.0F || EXP##l(0.0L) != 1.0L) \
+ link_failure_##EXP##_0()
+
+ EXP_0(exp);
+ EXP_0(exp2);
+ EXP_0(exp10);
+ EXP_0(pow10);
+
+ /* Test expN(1) -> N. */
+#define EXP_N(EXP, BASE) \
+ extern void link_failure_##EXP##_N(void); \
+ if (EXP(1.0) != BASE || EXP##f(1.0F) != BASE##F || EXP##l(1.0L) != BASE##L) \
+ link_failure_##EXP##_N()
+
+ EXP_N(exp, M_E);
+ EXP_N(exp2, 2.0);
+ EXP_N(exp10, 10.0);
+ EXP_N(pow10, 10.0);
+
+ /* Test expN(integer) -> N*N*N*... */
+#define EXP_INT(EXP, BASE) \
+ extern void link_failure_##EXP##_INT(void); \
+ if (EXP(5.0) < (BASE)*(BASE)*(BASE)*(BASE)*(BASE) - PREC \
+ || EXP(5.0) > (BASE)*(BASE)*(BASE)*(BASE)*(BASE) + PREC \
+ || EXP##f(5.0F) < (BASE##F)*(BASE##F)*(BASE##F)*(BASE##F)*(BASE##F) -PRECF \
+ || EXP##f(5.0F) > (BASE##F)*(BASE##F)*(BASE##F)*(BASE##F)*(BASE##F) +PRECF \
+ || EXP##l(5.0L) < (BASE##L)*(BASE##L)*(BASE##L)*(BASE##L)*(BASE##L) -PRECL \
+ || EXP##l(5.0L) > (BASE##L)*(BASE##L)*(BASE##L)*(BASE##L)*(BASE##L) +PRECL) \
+ link_failure_##EXP##_INT()
+
+ EXP_INT(exp, M_E);
+ EXP_INT(exp2, 2.0);
+ EXP_INT(exp10, 10.0);
+ EXP_INT(pow10, 10.0);
+
+ /* Test expN(logN(x)) -> x. */
+#define EXPLOG_SAME(EXP, LOG) \
+ extern void link_failure_##EXP##_##LOG##_same(void); \
+ if (EXP(LOG(d1)) != d1 || EXP##f(LOG##f(f1)) != f1 \
+ || EXP##l(LOG##l(ld1)) != ld1) link_failure_##EXP##_##LOG##_same()
+
+ EXPLOG_SAME(exp, log);
+ EXPLOG_SAME(exp2, log2);
+ EXPLOG_SAME(exp10, log10);
+ EXPLOG_SAME(pow10, log10);
+
+ /* Test expN(x)*expN(y)) -> expN(x+y). */
+#define EXPXEXP(EXP) \
+ extern void link_failure_##EXP##X##EXP(void); \
+ if (EXP(d1)*EXP(d2) != EXP(d1+d2) || EXP##f(f1)*EXP##f(f2) != EXP##f(f1+f2) \
+ || EXP##l(ld1)*EXP##l(ld2) != EXP##l(ld1+ld2)) link_failure_##EXP##X##EXP()
+
+ EXPXEXP(exp);
+ EXPXEXP(exp2);
+ EXPXEXP(exp10);
+ EXPXEXP(pow10);
+
+ /* Test x/expN(y) -> x*expN(-y). */
+ /* Test expN(x)/expN(y) -> expN(x-y). */
+#define DIVEXP(EXP) \
+ extern void link_failure_div1_##EXP(void); \
+ if (d1/EXP(d2) != d1*EXP(-d2) || f1/EXP##f(f2) != f1*EXP##f(-f2) \
+ || ld1/EXP##l(ld2) != ld1*EXP##l(-ld2)) link_failure_div1_##EXP(); \
+ extern void link_failure_div2_##EXP(void); \
+ if (EXP(d1)/EXP(d2) != EXP(d1-d2) || EXP##f(f1)/EXP##f(f2) != EXP##f(f1-f2) \
+ || EXP##l(ld1)/EXP##l(ld2) != EXP##l(ld1-ld2)) link_failure_div2_##EXP()
+
+ DIVEXP(exp);
+ DIVEXP(exp2);
+ DIVEXP(exp10);
+ DIVEXP(pow10);
+}
+
+int main (void)
+{
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/builtin-frexp-1.c b/gcc/testsuite/gcc.dg/torture/builtin-frexp-1.c
new file mode 100644
index 000000000..3ef23648a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/builtin-frexp-1.c
@@ -0,0 +1,137 @@
+/* Copyright (C) 2007 Free Software Foundation.
+
+ Verify that built-in folding of frexp is correctly performed by the
+ compiler.
+
+ Origin: Kaveh R. Ghazi, February 21, 2007. */
+
+/* { dg-do link } */
+/* { dg-options "-fno-finite-math-only" { target sh*-*-* } } */
+/* In order to fold algebraic exprs below, targets with "composite"
+ floating point formats need -funsafe-math-optimizations. */
+/* { dg-options "-funsafe-math-optimizations" { target mips*-*-irix6* powerpc*-*-* } } */
+
+extern void link_error(int);
+
+/* Return TRUE if the sign of X != sign of Y. This is important when
+ comparing signed zeros. */
+#define CKSGN_F(X,Y) \
+ (__builtin_copysignf(1.0F,(X)) != __builtin_copysignf(1.0F,(Y)))
+#define CKSGN(X,Y) \
+ (__builtin_copysign(1.0,(X)) != __builtin_copysign(1.0,(Y)))
+#define CKSGN_L(X,Y) \
+ (__builtin_copysignl(1.0L,(X)) != __builtin_copysignl(1.0L,(Y)))
+
+/* We can only check the exponent when optimizing since we rely on
+ other optimizations to propagate the value. TRUE means an error
+ occurred. */
+#ifdef __OPTIMIZE__
+#define CKEXP(X,Y) X != Y
+#else
+#define CKEXP(X,Y) 0
+#endif
+
+/* Test that frexp(ARG,&i) == RES && i == EXP. Check the sign in
+ case we get -0.0. */
+#define TESTIT_FREXP(ARG,RES,EXP) do { \
+ int i = 12345; \
+ if (__builtin_frexpf(ARG##f,&i) != RES##f \
+ || CKEXP(i,EXP) \
+ || CKSGN_F(__builtin_frexpf(ARG##f,&i),RES##f)) \
+ link_error(__LINE__); \
+ i = 12345; \
+ if (__builtin_frexp(ARG,&i) != RES \
+ || CKEXP(i,EXP) \
+ || CKSGN(__builtin_frexp(ARG,&i),RES)) \
+ link_error(__LINE__); \
+ i = 12345; \
+ if (__builtin_frexpl(ARG##l,&i) != RES##l \
+ || CKEXP(i,EXP) \
+ || CKSGN_L(__builtin_frexpl(ARG##l,&i),RES##l)) \
+ link_error(__LINE__); \
+ } while (0)
+
+/* Test that FUNCRES(frexp(NEG FUNCARG(ARGARG),&i)) is false. Check
+ the sign as well. Ensure side-effects are evaluated in i. */
+#ifndef __SPU__
+#define TESTIT_FREXP2(NEG,FUNCARG,ARGARG,FUNCRES) do { \
+ int i=5; \
+ if (!__builtin_##FUNCRES##f(__builtin_frexpf(NEG __builtin_##FUNCARG##f(ARGARG),&i)) \
+ || CKSGN_F(__builtin_frexpf(NEG __builtin_##FUNCARG##f(ARGARG),(i++,&i)), NEG __builtin_##FUNCARG##f(ARGARG)) \
+ || CKEXP(i,6)) \
+ link_error(__LINE__); \
+ if (!__builtin_##FUNCRES(__builtin_frexp(NEG __builtin_##FUNCARG(ARGARG),&i)) \
+ || CKSGN(__builtin_frexp(NEG __builtin_##FUNCARG(ARGARG),(i++,&i)), NEG __builtin_##FUNCARG(ARGARG)) \
+ || CKEXP(i,7)) \
+ link_error(__LINE__); \
+ if (!__builtin_##FUNCRES##l(__builtin_frexpl(NEG __builtin_##FUNCARG##l(ARGARG),&i)) \
+ || CKSGN_L(__builtin_frexpl(NEG __builtin_##FUNCARG##l(ARGARG),(i++,&i)), NEG __builtin_##FUNCARG##l(ARGARG)) \
+ || CKEXP(i,8)) \
+ link_error(__LINE__); \
+ } while (0)
+#else
+#define TESTIT_FREXP2(NEG,FUNCARG,ARGARG,FUNCRES) do { \
+ int i=6; \
+ /* SPU single-precision floating point format does not support Inf or Nan. */ \
+ if (!__builtin_##FUNCRES(__builtin_frexp(NEG __builtin_##FUNCARG(ARGARG),&i)) \
+ || CKSGN(__builtin_frexp(NEG __builtin_##FUNCARG(ARGARG),(i++,&i)), NEG __builtin_##FUNCARG(ARGARG)) \
+ || CKEXP(i,7)) \
+ link_error(__LINE__); \
+ if (!__builtin_##FUNCRES##l(__builtin_frexpl(NEG __builtin_##FUNCARG##l(ARGARG),&i)) \
+ || CKSGN_L(__builtin_frexpl(NEG __builtin_##FUNCARG##l(ARGARG),(i++,&i)), NEG __builtin_##FUNCARG##l(ARGARG)) \
+ || CKEXP(i,8)) \
+ link_error(__LINE__); \
+ } while (0)
+#endif
+
+void __attribute__ ((__noinline__))
+foo(void)
+{
+ /* Test that frexp(ARG1,&i) -> ARG2 && i == ARG3. */
+ TESTIT_FREXP (-0x1p40, -0.5, 41);
+ TESTIT_FREXP (-0x1p30, -0.5, 31);
+ TESTIT_FREXP (-0x1p20, -0.5, 21);
+ TESTIT_FREXP (-0x1p10, -0.5, 11);
+ TESTIT_FREXP (-0x1p5, -0.5, 6);
+ TESTIT_FREXP (-100/3.0, -100/192.0, 6);
+ TESTIT_FREXP (-1.5, -0.75, 1);
+ TESTIT_FREXP (-1.0, -0.5, 1);
+ TESTIT_FREXP (-1/3.0, -2/3.0, -1);
+ TESTIT_FREXP (-1/9.0, -8/9.0, -3);
+ TESTIT_FREXP (-0x1p-5, -0.5, -4);
+ TESTIT_FREXP (-0x1p-10, -0.5, -9);
+ TESTIT_FREXP (-0x1p-20, -0.5, -19);
+ TESTIT_FREXP (-0x1p-30, -0.5, -29);
+ TESTIT_FREXP (-0x1p-40, -0.5, -39);
+ TESTIT_FREXP (-0.0, -0.0, 0);
+ TESTIT_FREXP (0.0, 0.0, 0);
+ TESTIT_FREXP (0x1p-40, 0.5, -39);
+ TESTIT_FREXP (0x1p-30, 0.5, -29);
+ TESTIT_FREXP (0x1p-20, 0.5, -19);
+ TESTIT_FREXP (0x1p-10, 0.5, -9);
+ TESTIT_FREXP (0x1p-5, 0.5, -4);
+ TESTIT_FREXP (1/9.0, 8/9.0, -3);
+ TESTIT_FREXP (1/3.0, 2/3.0, -1);
+ TESTIT_FREXP (1.0, 0.5, 1);
+ TESTIT_FREXP (1.5, 0.75, 1);
+ TESTIT_FREXP (100/3.0, 100/192.0, 6);
+ TESTIT_FREXP (0x1p5, 0.5, 6);
+ TESTIT_FREXP (0x1p10, 0.5, 11);
+ TESTIT_FREXP (0x1p20, 0.5, 21);
+ TESTIT_FREXP (0x1p30, 0.5, 31);
+ TESTIT_FREXP (0x1p40, 0.5, 41);
+
+ /* Test for frexp(+-Inf,&i) -> +-Inf and frexp(+-NaN,&i) -> +-NaN.
+ Exponent is left unspecified, but we test for side-effects. */
+ TESTIT_FREXP2 ( ,inf, , isinf);
+ TESTIT_FREXP2 (- ,inf, , isinf);
+ TESTIT_FREXP2 ( ,nan, "", isnan);
+ TESTIT_FREXP2 (- ,nan, "", isnan);
+}
+
+int main()
+{
+ foo ();
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/builtin-integral-1.c b/gcc/testsuite/gcc.dg/torture/builtin-integral-1.c
new file mode 100644
index 000000000..522646dd5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/builtin-integral-1.c
@@ -0,0 +1,69 @@
+/* Copyright (C) 2004 Free Software Foundation.
+
+ Verify that integral FP expressions are optimized.
+
+ Written by Kaveh Ghazi, 2004-03-16. */
+
+/* { dg-do link } */
+/* We need -ffinite-math-only so that we can fold "foo != foo", where
+ foo is a floating point expression. We need -fno-math-errno so
+ that various math functions are marked const/pure and can be
+ folded. */
+/* { dg-options "-ffinite-math-only -fno-math-errno" } */
+
+extern int link_failure (int);
+
+/* Test that the various FP truncation builtins detect integral
+ arguments. */
+#define CHECK_FN(MATHFN) \
+ if (__builtin_##MATHFN(i1) != i1) link_failure (__LINE__); \
+ if (__builtin_##MATHFN##f(i1) != i1) link_failure (__LINE__); \
+ if (__builtin_##MATHFN##l(i1) != i1) link_failure (__LINE__);
+
+#define CHECK_FN_RET(MATHFN, RET) \
+ if (__builtin_##MATHFN(i1) != (RET)(double)i1) link_failure (__LINE__); \
+ if (__builtin_##MATHFN##f(i1) != (RET)(float)i1) link_failure (__LINE__); \
+ if (__builtin_##MATHFN##l(i1) != (RET)(long double)i1) link_failure (__LINE__);
+
+ /* Check that various other integral expressions are detected. */
+#define CHECK_EXPR(EXPR,NAME) \
+ if (__builtin_ceill(EXPR) != (EXPR)) link_failure (__LINE__); \
+ if (__builtin_lroundl(EXPR) != (long)(long double)(EXPR)) link_failure (__LINE__);
+
+void __attribute__ ((__noinline__)) test (int i1, int i2)
+{
+ CHECK_FN(ceil);
+ CHECK_FN(floor);
+ CHECK_FN(nearbyint);
+ CHECK_FN(rint);
+ CHECK_FN(round);
+ CHECK_FN(trunc);
+ CHECK_FN_RET(lround, long);
+ CHECK_FN_RET(llround, long long);
+ CHECK_FN_RET(lrint, long);
+ CHECK_FN_RET(llrint, long long);
+ CHECK_FN_RET(lceil, long);
+ CHECK_FN_RET(llceil, long long);
+ CHECK_FN_RET(lfloor, long);
+ CHECK_FN_RET(llfloor, long long);
+
+ CHECK_EXPR (5.0, REAL_CST);
+ CHECK_EXPR (5.0F, REAL_CSTf);
+ CHECK_EXPR (5.0L, REAL_CSTl);
+ CHECK_EXPR ((double)i1, FLOAT_EXPR);
+ CHECK_EXPR ((float)i1, FLOAT_EXPRf);
+ CHECK_EXPR ((long double)i1, FLOAT_EXPRl);
+ CHECK_EXPR (__builtin_fabs(i1), ABS_EXPR);
+ CHECK_EXPR (__builtin_fabsf(i1), ABS_EXPRf);
+ CHECK_EXPR (__builtin_fabsl(i1), ABS_EXPRl);
+ CHECK_EXPR (((void)i1,(double)i2), COMPOUND_EXPR);
+ CHECK_EXPR ((double)i1+i2, PLUS_EXPR);
+ CHECK_EXPR ((double)i1-i2, MINUS_EXPR);
+ CHECK_EXPR ((double)i1*i2, MULT_EXPR);
+}
+
+int main (void)
+{
+ test (1, 2);
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/builtin-isinf_sign-1.c b/gcc/testsuite/gcc.dg/torture/builtin-isinf_sign-1.c
new file mode 100644
index 000000000..6dc2326ed
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/builtin-isinf_sign-1.c
@@ -0,0 +1,56 @@
+/* Copyright (C) 2008 Free Software Foundation.
+
+ Verify that __builtin_isinf_sign folds correctly.
+
+ Origin: Kaveh R. Ghazi, May 17, 2008. */
+
+/* { dg-do link } */
+
+/* All references to link_error should go away at compile-time. */
+extern void link_error(int);
+
+void __attribute__ ((__noinline__))
+foo (float f, double d, long double ld)
+{
+ /* Test the generic expansion of isinf_sign. */
+
+ if (__builtin_isinf_sign(f)
+ != (__builtin_isinf(f) ? (__builtin_signbitf(f) ? -1 : 1) : 0))
+ link_error (__LINE__);
+ if (__builtin_isinf_sign(d)
+ != (__builtin_isinf(d) ? (__builtin_signbit(d) ? -1 : 1) : 0))
+ link_error (__LINE__);
+ if (__builtin_isinf_sign(ld)
+ != (__builtin_isinf(ld) ? (__builtin_signbitl(ld) ? -1 : 1) : 0))
+ link_error (__LINE__);
+
+ /* In boolean contexts, GCC will fold the inner conditional
+ expression to 1. So isinf_sign folds to plain isinf. */
+
+ if ((_Bool)__builtin_isinf_sign(f) != (__builtin_isinf(f) != 0))
+ link_error (__LINE__);
+ if ((_Bool)__builtin_isinf_sign(d) != (__builtin_isinf(d) != 0))
+ link_error (__LINE__);
+ if ((_Bool)__builtin_isinf_sign(ld) != (__builtin_isinf(ld) != 0))
+ link_error (__LINE__);
+
+ if ((__builtin_isinf_sign(f) != 0) != (__builtin_isinf(f) != 0))
+ link_error (__LINE__);
+ if ((__builtin_isinf_sign(d) != 0) != (__builtin_isinf(d) != 0))
+ link_error (__LINE__);
+ if ((__builtin_isinf_sign(ld) != 0) != (__builtin_isinf(ld) != 0))
+ link_error (__LINE__);
+
+ if ((__builtin_isinf_sign(f) ? 5 : 6) != (__builtin_isinf(f) ? 5 : 6))
+ link_error (__LINE__);
+ if ((__builtin_isinf_sign(d) ? 5 : 6) != (__builtin_isinf(d) ? 5 : 6))
+ link_error (__LINE__);
+ if ((__builtin_isinf_sign(ld) ? 5 : 6) != (__builtin_isinf(ld) ? 5 : 6))
+ link_error (__LINE__);
+}
+
+int main (void)
+{
+ foo (1, 2, 3);
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/builtin-ldexp-1.c b/gcc/testsuite/gcc.dg/torture/builtin-ldexp-1.c
new file mode 100644
index 000000000..94560a8ab
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/builtin-ldexp-1.c
@@ -0,0 +1,216 @@
+/* Copyright (C) 2007 Free Software Foundation.
+
+ Verify that built-in folding of ldexp et al. is correctly performed
+ by the compiler.
+
+ Origin: Kaveh R. Ghazi, February 17, 2007. */
+
+/* { dg-do link } */
+/* { dg-options "-fno-finite-math-only" { target sh*-*-* } } */
+
+extern void link_error(int);
+
+/* Return TRUE if the sign of X != sign of Y. This is important when
+ comparing signed zeros. */
+#define CKSGN_F(X,Y) \
+ (__builtin_copysignf(1.0F,(X)) != __builtin_copysignf(1.0F,(Y)))
+#define CKSGN(X,Y) \
+ (__builtin_copysign(1.0,(X)) != __builtin_copysign(1.0,(Y)))
+#define CKSGN_L(X,Y) \
+ (__builtin_copysignl(1.0L,(X)) != __builtin_copysignl(1.0L,(Y)))
+
+/* Test that FUNC(ARG1,ARG2) == RES. Check the sign for -0.0. */
+#define TESTIT(FUNC,ARG1,ARG2,RES) do { \
+ if (__builtin_##FUNC##f(ARG1##f,ARG2) != RES##f \
+ || CKSGN_F(__builtin_##FUNC##f(ARG1##f,ARG2),RES##f)) \
+ link_error(__LINE__); \
+ if (__builtin_##FUNC(ARG1,ARG2) != RES \
+ || CKSGN(__builtin_##FUNC(ARG1,ARG2),RES)) \
+ link_error(__LINE__); \
+ if (__builtin_##FUNC##l(ARG1##l,ARG2) != RES##l \
+ || CKSGN_L(__builtin_##FUNC##l(ARG1##l,ARG2),RES##l)) \
+ link_error(__LINE__); \
+ } while (0)
+
+/* Test that (long)FUNC(ARG1,ARG2) == (long)RES. The cast is
+ necessary when RES is not a constant. */
+#define TESTIT2(FUNC,ARG1,ARG2,RES) do { \
+ if ((long)__builtin_##FUNC##f(ARG1##f,ARG2) != (long)RES##f) \
+ link_error(__LINE__); \
+ if ((long)__builtin_##FUNC(ARG1,ARG2) != (long)RES) \
+ link_error(__LINE__); \
+ if ((long)__builtin_##FUNC##l(ARG1##l,ARG2) != (long)RES##l) \
+ link_error(__LINE__); \
+ } while (0)
+
+/* Test that FUNCRES(FUNC(NEG FUNCARG(ARGARG),ARG2)) is false. Check
+ the sign as well. */
+#ifndef __SPU__
+#define TESTIT3(FUNC,NEG,FUNCARG,ARGARG,ARG2,FUNCRES) do { \
+ if (!__builtin_##FUNCRES##f(__builtin_##FUNC##f(NEG __builtin_##FUNCARG##f(ARGARG),ARG2)) \
+ || CKSGN_F(__builtin_##FUNC##f(NEG __builtin_##FUNCARG##f(ARGARG),ARG2), NEG __builtin_##FUNCARG##f(ARGARG))) \
+ link_error(__LINE__); \
+ if (!__builtin_##FUNCRES(__builtin_##FUNC(NEG __builtin_##FUNCARG(ARGARG),ARG2)) \
+ || CKSGN(__builtin_##FUNC(NEG __builtin_##FUNCARG(ARGARG),ARG2), NEG __builtin_##FUNCARG(ARGARG))) \
+ link_error(__LINE__); \
+ if (!__builtin_##FUNCRES##l(__builtin_##FUNC##l(NEG __builtin_##FUNCARG##l(ARGARG),ARG2)) \
+ || CKSGN_L(__builtin_##FUNC##l(NEG __builtin_##FUNCARG##l(ARGARG),ARG2), NEG __builtin_##FUNCARG##l(ARGARG))) \
+ link_error(__LINE__); \
+ } while (0)
+#else
+#define TESTIT3(FUNC,NEG,FUNCARG,ARGARG,ARG2,FUNCRES) do { \
+ /* SPU single-precision floating point format does not support Inf or Nan. */ \
+ if (!__builtin_##FUNCRES(__builtin_##FUNC(NEG __builtin_##FUNCARG(ARGARG),ARG2)) \
+ || CKSGN(__builtin_##FUNC(NEG __builtin_##FUNCARG(ARGARG),ARG2), NEG __builtin_##FUNCARG(ARGARG))) \
+ link_error(__LINE__); \
+ if (!__builtin_##FUNCRES##l(__builtin_##FUNC##l(NEG __builtin_##FUNCARG##l(ARGARG),ARG2)) \
+ || CKSGN_L(__builtin_##FUNC##l(NEG __builtin_##FUNCARG##l(ARGARG),ARG2), NEG __builtin_##FUNCARG##l(ARGARG))) \
+ link_error(__LINE__); \
+ } while (0)
+#endif
+
+/* Using foo==MIN/MAX float values, test that FUNC(foo,EXP) == foo*exp2(EXP),
+ and also that FUNC(foo,-EXP) == foo*exp2(-EXP). */
+#define TESTIT4(FUNC,EXP) do { \
+ if (__builtin_##FUNC##f(__FLT_MIN__,EXP) != __FLT_MIN__*__builtin_exp2f(EXP)) \
+ link_error(__LINE__); \
+ if (__builtin_##FUNC##f(-__FLT_MIN__,EXP) != -__FLT_MIN__*__builtin_exp2f(EXP)) \
+ link_error(__LINE__); \
+ if (__builtin_##FUNC(__DBL_MIN__,EXP) != __DBL_MIN__*__builtin_exp2(EXP)) \
+ link_error(__LINE__); \
+ if (__builtin_##FUNC(-__DBL_MIN__,EXP) != -__DBL_MIN__*__builtin_exp2(EXP)) \
+ link_error(__LINE__); \
+ if (__builtin_##FUNC##l(__LDBL_MIN__,EXP) != __LDBL_MIN__*__builtin_exp2l(EXP)) \
+ link_error(__LINE__); \
+ if (__builtin_##FUNC##l(-__LDBL_MIN__,EXP) != -__LDBL_MIN__*__builtin_exp2l(EXP)) \
+ link_error(__LINE__); \
+ if (__builtin_##FUNC##f(__FLT_MAX__,-EXP) != __FLT_MAX__*__builtin_exp2f(-EXP)) \
+ link_error(__LINE__); \
+ if (__builtin_##FUNC##f(-__FLT_MAX__,-EXP) != -__FLT_MAX__*__builtin_exp2f(-EXP)) \
+ link_error(__LINE__); \
+ if (__builtin_##FUNC(__DBL_MAX__,-EXP) != __DBL_MAX__*__builtin_exp2(-EXP)) \
+ link_error(__LINE__); \
+ if (__builtin_##FUNC(-__DBL_MAX__,-EXP) != -__DBL_MAX__*__builtin_exp2(-EXP)) \
+ link_error(__LINE__); \
+ if (__builtin_##FUNC##l(__LDBL_MAX__,-EXP) != __LDBL_MAX__*__builtin_exp2l(-EXP)) \
+ link_error(__LINE__); \
+ if (__builtin_##FUNC##l(-__LDBL_MAX__,-EXP) != -__LDBL_MAX__*__builtin_exp2l(-EXP)) \
+ link_error(__LINE__); \
+ } while (0)
+
+void __attribute__ ((__noinline__))
+foo(float xf, double x, long double xl, int i, long l)
+{
+ /* f(0.0, i) -> 0.0 and f(-0.0, i) -> -0.0. */
+ TESTIT (ldexp, 0.0, i, 0.0);
+ TESTIT (ldexp, -0.0, i, -0.0);
+ TESTIT (scalbn, 0.0, i, 0.0);
+ TESTIT (scalbn, -0.0, i, -0.0);
+ TESTIT (scalbln, 0.0, l, 0.0);
+ TESTIT (scalbln, -0.0, l, -0.0);
+
+ /* f(x,0) -> x. */
+ TESTIT2 (ldexp, x, 0, x);
+ TESTIT2 (scalbn, x, 0, x);
+ TESTIT2 (scalbln, x, 0, x);
+
+ /* f(Inf,i) -> Inf and f(NaN,i) -> NaN. */
+ TESTIT3 (ldexp, , inf, , i, isinf);
+ TESTIT3 (ldexp, -, inf, , i, isinf);
+ TESTIT3 (ldexp, , nan, "", i, isnan);
+ TESTIT3 (ldexp, -, nan, "", i, isnan);
+
+ TESTIT3 (scalbn, , inf, , i, isinf);
+ TESTIT3 (scalbn, -, inf, , i, isinf);
+ TESTIT3 (scalbn, , nan, "", i, isnan);
+ TESTIT3 (scalbn, -, nan, "", i, isnan);
+
+ TESTIT3 (scalbln, , inf, , i, isinf);
+ TESTIT3 (scalbln, -, inf, , i, isinf);
+ TESTIT3 (scalbln, , nan, "", i, isnan);
+ TESTIT3 (scalbln, -, nan, "", i, isnan);
+
+ /* Evaluate when both arguments are constant. */
+ TESTIT (ldexp, 5.0, 3, 40.0);
+ TESTIT (ldexp, -5.0, 3, -40.0);
+ TESTIT (ldexp, 5.0, -3, 0.625);
+ TESTIT (ldexp, -5.0, -3, -0.625);
+
+ TESTIT (ldexp, 1000.0, 5, 32000.0);
+ TESTIT (ldexp, -1000.0, 5, -32000.0);
+ TESTIT (ldexp, 1000.0, -5, 31.25);
+ TESTIT (ldexp, -1000.0, -5, -31.25);
+
+ /* f(x,N) -> x*exp2(N), using MIN/MAX constants for x and constant N. */
+ TESTIT4 (ldexp, 1);
+ TESTIT4 (ldexp, 2);
+ TESTIT4 (ldexp, 3);
+ TESTIT4 (ldexp, 5);
+ TESTIT4 (ldexp, 9);
+ TESTIT4 (ldexp, 10);
+ TESTIT4 (ldexp, 12);
+ TESTIT4 (ldexp, 18);
+ TESTIT4 (ldexp, 25);
+ TESTIT4 (ldexp, 50);
+ TESTIT4 (ldexp, 75);
+ TESTIT4 (ldexp, 100);
+ TESTIT4 (ldexp, 123);
+
+ /* These are folded when float radix is two. */
+#if __FLT_RADIX__ == 2
+ TESTIT (scalbn, 5.0, 3, 40.0);
+ TESTIT (scalbn, -5.0, 3, -40.0);
+ TESTIT (scalbn, 5.0, -3, 0.625);
+ TESTIT (scalbn, -5.0, -3, -0.625);
+
+ TESTIT (scalbn, 1000.0, 5, 32000.0);
+ TESTIT (scalbn, -1000.0, 5, -32000.0);
+ TESTIT (scalbn, 1000.0, -5, 31.25);
+ TESTIT (scalbn, -1000.0, -5, -31.25);
+
+ TESTIT4 (scalbn, 1);
+ TESTIT4 (scalbn, 2);
+ TESTIT4 (scalbn, 3);
+ TESTIT4 (scalbn, 5);
+ TESTIT4 (scalbn, 9);
+ TESTIT4 (scalbn, 10);
+ TESTIT4 (scalbn, 12);
+ TESTIT4 (scalbn, 18);
+ TESTIT4 (scalbn, 25);
+ TESTIT4 (scalbn, 50);
+ TESTIT4 (scalbn, 75);
+ TESTIT4 (scalbn, 100);
+ TESTIT4 (scalbn, 123);
+
+ TESTIT (scalbln, 5.0, 3, 40.0);
+ TESTIT (scalbln, -5.0, 3, -40.0);
+ TESTIT (scalbln, 5.0, -3, 0.625);
+ TESTIT (scalbln, -5.0, -3, -0.625);
+
+ TESTIT (scalbln, 1000.0, 5, 32000.0);
+ TESTIT (scalbln, -1000.0, 5, -32000.0);
+ TESTIT (scalbln, 1000.0, -5, 31.25);
+ TESTIT (scalbln, -1000.0, -5, -31.25);
+
+ TESTIT4 (scalbln, 1);
+ TESTIT4 (scalbln, 2);
+ TESTIT4 (scalbln, 3);
+ TESTIT4 (scalbln, 5);
+ TESTIT4 (scalbln, 9);
+ TESTIT4 (scalbln, 10);
+ TESTIT4 (scalbln, 12);
+ TESTIT4 (scalbln, 18);
+ TESTIT4 (scalbln, 25);
+ TESTIT4 (scalbln, 50);
+ TESTIT4 (scalbln, 75);
+ TESTIT4 (scalbln, 100);
+ TESTIT4 (scalbln, 123);
+#endif
+}
+
+int main()
+{
+ foo (0, 0, 0, 0, 0);
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/builtin-logb-1.c b/gcc/testsuite/gcc.dg/torture/builtin-logb-1.c
new file mode 100644
index 000000000..25d0f9106
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/builtin-logb-1.c
@@ -0,0 +1,192 @@
+/* Copyright (C) 2007 Free Software Foundation.
+
+ Verify that built-in folding of logb, ilogb and significand is
+ correctly performed by the compiler.
+
+ Origin: Kaveh R. Ghazi, February 22, 2007. */
+
+/* { dg-do link } */
+/* { dg-options "-fno-finite-math-only" { target sh*-*-* } } */
+/* In order to fold algebraic exprs below, targets with "composite"
+ floating point formats need -funsafe-math-optimizations. */
+/* { dg-options "-funsafe-math-optimizations" { target mips*-*-irix6* powerpc*-*-* } } */
+
+extern void link_error(int);
+
+/* Return TRUE if the sign of X != sign of Y. This is important when
+ comparing signed zeros. */
+#define CKSGN_F(X,Y) \
+ (__builtin_copysignf(1.0F,(X)) != __builtin_copysignf(1.0F,(Y)))
+#define CKSGN(X,Y) \
+ (__builtin_copysign(1.0,(X)) != __builtin_copysign(1.0,(Y)))
+#define CKSGN_L(X,Y) \
+ (__builtin_copysignl(1.0L,(X)) != __builtin_copysignl(1.0L,(Y)))
+
+/* Test that FUNC(ARG) == RES. Check the sign in case we get -0.0. */
+#define TESTIT(FUNC,ARG,RES) do { \
+ if (__builtin_##FUNC##f(ARG##f) != RES##f \
+ || CKSGN_F(__builtin_##FUNC##f(ARG##f),RES##f)) \
+ link_error(__LINE__); \
+ if (__builtin_##FUNC(ARG) != RES \
+ || CKSGN(__builtin_##FUNC(ARG),RES)) \
+ link_error(__LINE__); \
+ if (__builtin_##FUNC##l(ARG##l) != RES##l \
+ || CKSGN_L(__builtin_##FUNC##l(ARG##l),RES##l)) \
+ link_error(__LINE__); \
+ } while (0)
+
+/* Test that FUNC(ARG) == RES. RES is an int so it can't be -0.0. */
+#define TESTIT2(FUNC,ARG,RES) do { \
+ if (__builtin_##FUNC##f(ARG##f) != RES) \
+ link_error(__LINE__); \
+ if (__builtin_##FUNC(ARG) != RES) \
+ link_error(__LINE__); \
+ if (__builtin_##FUNC##l(ARG##l) != RES) \
+ link_error(__LINE__); \
+ } while (0)
+
+/* Test if FUNCRES(FUNC(NEG FUNCARG(ARGARG))) is false. Check the
+ sign as well. */
+#ifndef __SPU__
+#define TESTIT3(FUNC,NEG,FUNCARG,ARGARG,FUNCRES) do { \
+ if (!__builtin_##FUNCRES##f(__builtin_##FUNC(NEG __builtin_##FUNCARG##f(ARGARG))) \
+ || CKSGN_F(__builtin_##FUNC##f(NEG __builtin_##FUNCARG##f(ARGARG)), NEG __builtin_##FUNCARG##f(ARGARG))) \
+ link_error(__LINE__); \
+ if (!__builtin_##FUNCRES(__builtin_##FUNC(NEG __builtin_##FUNCARG(ARGARG))) \
+ || CKSGN(__builtin_##FUNC(NEG __builtin_##FUNCARG(ARGARG)), NEG __builtin_##FUNCARG(ARGARG))) \
+ link_error(__LINE__); \
+ if (!__builtin_##FUNCRES##l(__builtin_##FUNC##l(NEG __builtin_##FUNCARG##l(ARGARG))) \
+ || CKSGN_L(__builtin_##FUNC##l(NEG __builtin_##FUNCARG##l(ARGARG)), NEG __builtin_##FUNCARG##l(ARGARG))) \
+ link_error(__LINE__); \
+ } while (0)
+#else
+#define TESTIT3(FUNC,NEG,FUNCARG,ARGARG,FUNCRES) do { \
+ /* SPU single-precision floating point format does not support Inf or Nan. */ \
+ if (!__builtin_##FUNCRES(__builtin_##FUNC(NEG __builtin_##FUNCARG(ARGARG))) \
+ || CKSGN(__builtin_##FUNC(NEG __builtin_##FUNCARG(ARGARG)), NEG __builtin_##FUNCARG(ARGARG))) \
+ link_error(__LINE__); \
+ if (!__builtin_##FUNCRES##l(__builtin_##FUNC##l(NEG __builtin_##FUNCARG##l(ARGARG))) \
+ || CKSGN_L(__builtin_##FUNC##l(NEG __builtin_##FUNCARG##l(ARGARG)), NEG __builtin_##FUNCARG##l(ARGARG))) \
+ link_error(__LINE__); \
+ } while (0)
+#endif
+
+void __attribute__ ((__noinline__))
+foo(void)
+{
+ /* If radix == 2, test that logb(ARG2) -> ARG3. */
+#if __FLT_RADIX__ == 2
+ TESTIT (logb, -0x1p40, 40.0);
+ TESTIT (logb, -0x1p30, 30.0);
+ TESTIT (logb, -0x1p20, 20.0);
+ TESTIT (logb, -0x1p10, 10.0);
+ TESTIT (logb, -0x1p5, 5.0);
+ TESTIT (logb, -100/3.0, 5.0);
+ TESTIT (logb, -2.0, 1.0);
+ TESTIT (logb, -1.5, 0.0);
+ TESTIT (logb, -1.0, 0.0);
+ TESTIT (logb, -1/3.0, -2.0);
+ TESTIT (logb, -1/9.0, -4.0);
+ TESTIT (logb, -0x1p-5, -5.0);
+ TESTIT (logb, -0x1p-10, -10.0);
+ TESTIT (logb, -0x1p-20, -20.0);
+ TESTIT (logb, -0x1p-30, -30.0);
+ TESTIT (logb, -0x1p-40, -40.0);
+
+ TESTIT (logb, 0x1p-40, -40.0);
+ TESTIT (logb, 0x1p-30, -30.0);
+ TESTIT (logb, 0x1p-20, -20.0);
+ TESTIT (logb, 0x1p-10, -10.0);
+ TESTIT (logb, 0x1p-5, -5.0);
+ TESTIT (logb, 1/9.0, -4.0);
+ TESTIT (logb, 1/3.0, -2.0);
+ TESTIT (logb, 1.0, 0.0);
+ TESTIT (logb, 1.5, 0.0);
+ TESTIT (logb, 2.0, 1.0);
+ TESTIT (logb, 100/3.0, 5.0);
+ TESTIT (logb, 0x1p5, 5.0);
+ TESTIT (logb, 0x1p10, 10.0);
+ TESTIT (logb, 0x1p20, 20.0);
+ TESTIT (logb, 0x1p30, 30.0);
+ TESTIT (logb, 0x1p40, 40.0);
+#endif
+
+ /* If radix == 2, test that ilogb(ARG2) -> ARG3. */
+#if __FLT_RADIX__ == 2
+ TESTIT2 (ilogb, -0x1p40, 40);
+ TESTIT2 (ilogb, -0x1p30, 30);
+ TESTIT2 (ilogb, -0x1p20, 20);
+ TESTIT2 (ilogb, -0x1p10, 10);
+ TESTIT2 (ilogb, -0x1p5, 5);
+ TESTIT2 (ilogb, -100/3.0, 5);
+ TESTIT2 (ilogb, -2.0, 1);
+ TESTIT2 (ilogb, -1.5, 0);
+ TESTIT2 (ilogb, -1.0, 0);
+ TESTIT2 (ilogb, -1/3.0, -2);
+ TESTIT2 (ilogb, -1/9.0, -4);
+ TESTIT2 (ilogb, -0x1p-5, -5);
+ TESTIT2 (ilogb, -0x1p-10, -10);
+ TESTIT2 (ilogb, -0x1p-20, -20);
+ TESTIT2 (ilogb, -0x1p-30, -30);
+ TESTIT2 (ilogb, -0x1p-40, -40);
+
+ TESTIT2 (ilogb, 0x1p-40, -40);
+ TESTIT2 (ilogb, 0x1p-30, -30);
+ TESTIT2 (ilogb, 0x1p-20, -20);
+ TESTIT2 (ilogb, 0x1p-10, -10);
+ TESTIT2 (ilogb, 0x1p-5, -5);
+ TESTIT2 (ilogb, 1/9.0, -4);
+ TESTIT2 (ilogb, 1/3.0, -2);
+ TESTIT2 (ilogb, 1.0, 0);
+ TESTIT2 (ilogb, 1.5, 0);
+ TESTIT2 (ilogb, 2.0, 1);
+ TESTIT2 (ilogb, 100/3.0, 5);
+ TESTIT2 (ilogb, 0x1p5, 5);
+ TESTIT2 (ilogb, 0x1p10, 10);
+ TESTIT2 (ilogb, 0x1p20, 20);
+ TESTIT2 (ilogb, 0x1p30, 30);
+ TESTIT2 (ilogb, 0x1p40, 40);
+#endif
+
+ /* If radix == 2, test that significand(ARG2) -> ARG3. Zero always
+ folds regardless of the radix. */
+ TESTIT (significand, -0.0, -0.0);
+ TESTIT (significand, 0.0, 0.0);
+
+#if __FLT_RADIX__ == 2
+ TESTIT (significand, -0x1p5, -1.0);
+ TESTIT (significand, -100/3.0, -100/96.0);
+ TESTIT (significand, -1.5, -1.5);
+ TESTIT (significand, -1.0, -1.0);
+ TESTIT (significand, -1/3.0, -4/3.0);
+ TESTIT (significand, -1/9.0, -16/9.0);
+ TESTIT (significand, -0x1p-5, -1.0);
+
+ TESTIT (significand, 0x1p-5, 1.0);
+ TESTIT (significand, 1/9.0, 16/9.0);
+ TESTIT (significand, 1/3.0, 4/3.0);
+ TESTIT (significand, 1.0, 1.0);
+ TESTIT (significand, 1.5, 1.5);
+ TESTIT (significand, 100/3.0, 100/96.0);
+ TESTIT (significand, 0x1p5, 1.0);
+#endif
+
+ /* Test for f(+-Inf) -> +-Inf and f(+-NaN) -> +-NaN, regardless of
+ the radix. */
+ TESTIT3 (logb, ,inf, , isinf);
+ TESTIT3 (logb, - ,inf, , isinf);
+ TESTIT3 (logb, ,nan, "", isnan);
+ TESTIT3 (logb, - ,nan, "", isnan);
+
+ TESTIT3 (significand, ,inf, , isinf);
+ TESTIT3 (significand, - ,inf, , isinf);
+ TESTIT3 (significand, ,nan, "", isnan);
+ TESTIT3 (significand, - ,nan, "", isnan);
+}
+
+int main()
+{
+ foo ();
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/builtin-math-1.c b/gcc/testsuite/gcc.dg/torture/builtin-math-1.c
new file mode 100644
index 000000000..d052f5347
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/builtin-math-1.c
@@ -0,0 +1,186 @@
+/* Copyright (C) 2002, 2003, 2004 Free Software Foundation.
+
+ Verify that built-in math function constant folding of constant
+ arguments is correctly performed by the compiler.
+
+ Written by Roger Sayle, 16th August 2002. */
+
+/* { dg-do link } */
+
+extern double atan (double);
+extern float atanf (float);
+extern long double atanl (long double);
+extern double cbrt (double);
+extern float cbrtf (float);
+extern long double cbrtl (long double);
+extern double cos (double);
+extern float cosf (float);
+extern long double cosl (long double);
+extern double exp (double);
+extern float expf (float);
+extern long double expl (long double);
+extern double log (double);
+extern float logf (float);
+extern long double logl (long double);
+extern double pow (double, double);
+extern float powf (float, float);
+extern long double powl (long double, long double);
+extern double sin (double);
+extern float sinf (float);
+extern long double sinl (long double);
+extern double sqrt (double);
+extern float sqrtf (float);
+extern long double sqrtl (long double);
+extern double tan (double);
+extern float tanf (float);
+extern long double tanl (long double);
+
+/* All references to link_error should go away at compile-time. */
+extern void link_error(void);
+
+void test (float f, double d, long double ld)
+{
+ if (sqrt (0.0) != 0.0)
+ link_error ();
+
+ if (sqrt (1.0) != 1.0)
+ link_error ();
+
+ if (cbrt (0.0) != 0.0)
+ link_error ();
+
+ if (cbrt (1.0) != 1.0)
+ link_error ();
+
+ if (cbrt (-1.0) != -1.0)
+ link_error ();
+
+ if (exp (0.0) != 1.0)
+ link_error ();
+
+ if (exp (1.0) <= 2.71 || exp (1.0) >= 2.72)
+ link_error ();
+
+ if (log (1.0) != 0.0)
+ link_error ();
+
+ if (sin (0.0) != 0.0)
+ link_error ();
+
+ if (cos (0.0) != 1.0)
+ link_error ();
+
+ if (tan (0.0) != 0.0)
+ link_error ();
+
+ if (atan (0.0) != 0.0)
+ link_error ();
+
+ if (4.0*atan (1.0) <= 3.14 || 4.0*atan (1.0) >= 3.15)
+ link_error ();
+
+ if (pow (d, 0.0) != 1.0)
+ link_error ();
+
+ if (pow (1.0, d) != 1.0)
+ link_error ();
+
+
+ if (sqrtf (0.0F) != 0.0F)
+ link_error ();
+
+ if (sqrtf (1.0F) != 1.0F)
+ link_error ();
+
+ if (cbrtf (0.0F) != 0.0F)
+ link_error ();
+
+ if (cbrtf (1.0F) != 1.0F)
+ link_error ();
+
+ if (cbrtf (-1.0F) != -1.0F)
+ link_error ();
+
+ if (expf (0.0F) != 1.0F)
+ link_error ();
+
+ if (expf (1.0F) <= 2.71F || expf (1.0F) >= 2.72F)
+ link_error ();
+
+ if (logf (1.0F) != 0.0F)
+ link_error ();
+
+ if (sinf (0.0F) != 0.0F)
+ link_error ();
+
+ if (cosf (0.0F) != 1.0F)
+ link_error ();
+
+ if (tanf (0.0F) != 0.0F)
+ link_error ();
+
+ if (atanf (0.0F) != 0.0F)
+ link_error ();
+
+ if (4.0F*atanf (1.0F) <= 3.14F || 4.0F*atanf (1.0F) >= 3.15F)
+ link_error ();
+
+ if (powf (f, 0.0F) != 1.0F)
+ link_error ();
+
+ if (powf (1.0F, f) != 1.0F)
+ link_error ();
+
+
+ if (sqrtl (0.0L) != 0.0L)
+ link_error ();
+
+ if (sqrtl (1.0L) != 1.0L)
+ link_error ();
+
+ if (cbrtl (0.0L) != 0.0L)
+ link_error ();
+
+ if (cbrtl (1.0L) != 1.0L)
+ link_error ();
+
+ if (cbrtl (-1.0L) != -1.0L)
+ link_error ();
+
+ if (expl (0.0L) != 1.0L)
+ link_error ();
+
+ if (expl (1.0L) <= 2.71L || expl (1.0L) >= 2.72L)
+ link_error ();
+
+ if (logl (1.0L) != 0.0L)
+ link_error ();
+
+ if (sinl (0.0L) != 0.0L)
+ link_error ();
+
+ if (cosl (0.0L) != 1.0L)
+ link_error ();
+
+ if (tanl (0.0L) != 0.0L)
+ link_error ();
+
+ if (atanl (0.0) != 0.0L)
+ link_error ();
+
+ if (4.0L*atanl (1.0L) <= 3.14L || 4.0L*atanl (1.0L) >= 3.15L)
+ link_error ();
+
+ if (powl (ld, 0.0L) != 1.0L)
+ link_error ();
+
+ if (powl (1.0L, ld) != 1.0L)
+ link_error ();
+}
+
+int main()
+{
+ test (3.0, 3.0F, 3.0L);
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/builtin-math-2.c b/gcc/testsuite/gcc.dg/torture/builtin-math-2.c
new file mode 100644
index 000000000..7e2ff1383
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/builtin-math-2.c
@@ -0,0 +1,385 @@
+/* Copyright (C) 2006, 2007 Free Software Foundation.
+
+ Test things that should block GCC from optimizing compile-time
+ constants passed to a builtin transcendental function.
+
+ Origin: Kaveh R. Ghazi, October 22, 2006. */
+
+/* { dg-do compile } */
+/* { dg-options "-fdump-tree-original" } */
+
+extern void foof (float);
+extern void foo (double);
+extern void fool (long double);
+
+#define TESTIT(FUNC, ARG) do { \
+ foof (__builtin_##FUNC##f (ARG##F)); \
+ foo (__builtin_##FUNC (ARG)); \
+ fool (__builtin_##FUNC##l (ARG##L)); \
+} while (0)
+
+#define TESTIT2(FUNC, ARG1, ARG2) do { \
+ foof (__builtin_##FUNC##f (ARG1##F, ARG2##F)); \
+ foo (__builtin_##FUNC (ARG1, ARG2)); \
+ fool (__builtin_##FUNC##l (ARG1##L, ARG2##L)); \
+} while (0)
+
+#define TESTIT2_I1(FUNC, ARG1, ARG2) do { \
+ foof (__builtin_##FUNC##f (ARG1, ARG2##F)); \
+ foo (__builtin_##FUNC (ARG1, ARG2)); \
+ fool (__builtin_##FUNC##l (ARG1, ARG2##L)); \
+} while (0)
+
+#define TESTIT2_I2ALL(FUNC, ARGF, MAXF, ARGD, MAXD, ARGLD, MAXLD) do { \
+ foof (__builtin_##FUNC##f (ARGF, MAXF)); \
+ foo (__builtin_##FUNC (ARGD, MAXD)); \
+ fool (__builtin_##FUNC##l (ARGLD, MAXLD)); \
+} while (0)
+
+#define TESTIT2_I2(FUNC, ARG1, ARG2) do { \
+ foof (__builtin_##FUNC##f (ARG1##F, ARG2)); \
+ foo (__builtin_##FUNC (ARG1, ARG2)); \
+ fool (__builtin_##FUNC##l (ARG1##L, ARG2)); \
+} while (0)
+
+#define TESTIT_REMQUO(ARG1, ARG2) do { \
+ int quo; \
+ foof (__builtin_remquof (ARG1##F, ARG2##F, &quo)); \
+ foo (__builtin_remquo (ARG1, ARG2, &quo)); \
+ fool (__builtin_remquol (ARG1##L, ARG2##L, &quo)); \
+} while (0)
+
+#define TESTIT_REENT(FUNC,ARG1) do { \
+ int sg; \
+ foof (__builtin_##FUNC##f_r (ARG1##F, &sg)); \
+ foo (__builtin_##FUNC##_r (ARG1, &sg)); \
+ fool (__builtin_##FUNC##l_r (ARG1##L, &sg)); \
+} while (0)
+
+void bar()
+{
+ /* An argument of NaN is not evaluated at compile-time. */
+#ifndef __SPU__
+ foof (__builtin_exp2f (__builtin_nanf("")));
+#endif
+ foo (__builtin_exp2 (__builtin_nan("")));
+ fool (__builtin_exp2l (__builtin_nanl("")));
+
+ /* An argument of Inf/-Inf is not evaluated at compile-time. */
+#ifndef __SPU__
+ foof (__builtin_exp2f (__builtin_inff()));
+#endif
+ foo (__builtin_exp2 (__builtin_inf()));
+ fool (__builtin_exp2l (__builtin_infl()));
+#ifndef __SPU__
+ foof (__builtin_exp2f (-__builtin_inff()));
+#endif
+ foo (__builtin_exp2 (-__builtin_inf()));
+ fool (__builtin_exp2l (-__builtin_infl()));
+
+ /* Result overflows MPFR, which in version 2.2.x has 30 exponent bits. */
+ TESTIT (exp2, 0x1p50);
+ /* Result underflows MPFR, which in version 2.2.x has 30 exponent bits. */
+ TESTIT (exp2, -0x1p50);
+
+ /* Result overflows GCC's REAL_VALUE_TYPE, which has 26 exponent bits. */
+ TESTIT (exp2, 0x1p28);
+ /* Result underflows GCC's REAL_VALUE_TYPE, which has 26 exponent bits. */
+ TESTIT (exp2, -0x1p28);
+
+ /* Result overflows (even an extended) C double's mode. */
+ TESTIT (exp2, 0x1p24);
+ /* Result underflows (even an extended) C double's mode. */
+ TESTIT (exp2, -0x1p24);
+
+ /* Ensure that normal arguments/results are folded. */
+ TESTIT (exp2, 1.5);
+ TESTIT (exp2, -1.5);
+
+ /* The asin arg must be [-1 ... 1] inclusive. */
+ TESTIT (asin, -1.5);
+ TESTIT (asin, 1.5);
+
+ /* The acos arg must be [-1 ... 1] inclusive. */
+ TESTIT (acos, -1.5);
+ TESTIT (acos, 1.5);
+
+ /* The acosh arg must be [1 ... Inf] inclusive. */
+ TESTIT (acosh, 0.5);
+
+ /* The atanh arg must be [-1 ... 1] EXclusive. */
+ TESTIT (atanh, -1.0);
+ TESTIT (atanh, 1.0);
+
+ /* The log* arg must be [0 ... Inf] EXclusive. */
+ TESTIT (log, -1.0);
+ TESTIT (log, 0.0);
+ TESTIT (log, -0.0);
+
+ TESTIT (log2, -1.0);
+ TESTIT (log2, 0.0);
+ TESTIT (log2, -0.0);
+
+ TESTIT (log10, -1.0);
+ TESTIT (log10, 0.0);
+ TESTIT (log10, -0.0);
+
+ /* The log1p arg must be [-1 ... Inf] EXclusive. */
+ TESTIT (log1p, -2.0);
+ TESTIT (log1p, -1.0);
+
+ /* The tgamma arg errors with zero or negative integers. */
+ TESTIT (tgamma, 0.0);
+ TESTIT (tgamma, -0.0);
+ TESTIT (tgamma, -1.0);
+ TESTIT (tgamma, -2.0);
+ TESTIT (tgamma, -3.0);
+
+ /* An argument of NaN is not evaluated at compile-time. */
+#ifndef __SPU__
+ foof (__builtin_powf (__builtin_nanf(""), 2.5F));
+#endif
+ foo (__builtin_pow (__builtin_nan(""), 2.5));
+ fool (__builtin_powl (__builtin_nanl(""), 2.5L));
+#ifndef __SPU__
+ foof (__builtin_powf (2.5F, __builtin_nanf("")));
+#endif
+ foo (__builtin_pow (2.5, __builtin_nan("")));
+ fool (__builtin_powl (2.5L, __builtin_nanl("")));
+
+ /* An argument of Inf/-Inf is not evaluated at compile-time. */
+#ifndef __SPU__
+ foof (__builtin_powf (__builtin_inff(), 2.5F));
+#endif
+ foo (__builtin_pow (__builtin_inf(), 2.5));
+ fool (__builtin_powl (__builtin_infl(), 2.5L));
+#ifndef __SPU__
+ foof (__builtin_powf (-__builtin_inff(), 2.5F));
+#endif
+ foo (__builtin_pow (-__builtin_inf(), 2.5));
+ fool (__builtin_powl (-__builtin_infl(), 2.5L));
+#ifndef __SPU__
+ foof (__builtin_powf (2.5F, __builtin_inff()));
+#endif
+ foo (__builtin_pow (2.5, __builtin_inf()));
+ fool (__builtin_powl (2.5L, __builtin_infl()));
+#ifndef __SPU__
+ foof (__builtin_powf (2.5F, -__builtin_inff()));
+#endif
+ foo (__builtin_pow (2.5, -__builtin_inf()));
+ fool (__builtin_powl (2.5L, -__builtin_infl()));
+
+ /* Check for Inv/NaN return values. */
+ TESTIT2 (pow, -0.0, -4.5); /* Returns Inf */
+ TESTIT2 (pow, 0.0, -4.5); /* Returns Inf */
+ TESTIT2 (pow, -3.0, -4.5); /* Returns NaN */
+
+ /* Check for overflow/underflow. */
+ foof (__builtin_powf (__FLT_MAX__, 3.5F));
+ foo (__builtin_pow (__DBL_MAX__, 3.5));
+ fool (__builtin_powl (__LDBL_MAX__, 3.5L));
+ TESTIT2 (pow, 2.0, 0x1p50);
+ foof (__builtin_powf (__FLT_MAX__, -3.5F));
+ foo (__builtin_pow (__DBL_MAX__, -3.5));
+ fool (__builtin_powl (__LDBL_MAX__, -3.5L));
+ TESTIT2 (pow, 2.0, -0x1p50);
+
+ /* The sqrt arg must be [0 ... Inf] inclusive. */
+ TESTIT (sqrt, -0.5);
+ TESTIT (sqrt, -0.0);
+ TESTIT (sqrt, 0.0);
+
+ /* Check for overflow/underflow. */
+
+ /* These adjustments are too big. */
+#define FLT_EXP_ADJ (2*(__FLT_MAX_EXP__-__FLT_MIN_EXP__)+1)
+#define DBL_EXP_ADJ (2*(__DBL_MAX_EXP__-__DBL_MIN_EXP__)+1)
+#define LDBL_EXP_ADJ (2*(__LDBL_MAX_EXP__-__LDBL_MIN_EXP__)+1)
+
+ TESTIT2_I2 (ldexp, 1.0, __INT_MAX__);
+ TESTIT2_I2 (ldexp, 1.0, -__INT_MAX__-1);
+ TESTIT2_I2 (ldexp, -1.0, __INT_MAX__);
+ TESTIT2_I2 (ldexp, -1.0, -__INT_MAX__-1);
+ TESTIT2_I2ALL (ldexp, __FLT_MIN__, FLT_EXP_ADJ, __DBL_MIN__,
+ DBL_EXP_ADJ, __LDBL_MIN__, LDBL_EXP_ADJ);
+ TESTIT2_I2ALL (ldexp, __FLT_MAX__, -FLT_EXP_ADJ, __DBL_MAX__,
+ -DBL_EXP_ADJ, __LDBL_MAX__, -LDBL_EXP_ADJ);
+ TESTIT2_I2ALL (ldexp, __FLT_MIN__, __FLT_MIN_EXP__, __DBL_MIN__,
+ __DBL_MIN_EXP__, __LDBL_MIN__, __LDBL_MIN_EXP__);
+ TESTIT2_I2ALL (ldexp, __FLT_MAX__, __FLT_MAX_EXP__, __DBL_MAX__,
+ __DBL_MAX_EXP__, __LDBL_MAX__, __LDBL_MAX_EXP__);
+
+ TESTIT2_I2 (scalbn, 1.0, __INT_MAX__);
+ TESTIT2_I2 (scalbn, 1.0, -__INT_MAX__-1);
+ TESTIT2_I2 (scalbn, -1.0, __INT_MAX__);
+ TESTIT2_I2 (scalbn, -1.0, -__INT_MAX__-1);
+ TESTIT2_I2ALL (scalbn, __FLT_MIN__, FLT_EXP_ADJ, __DBL_MIN__,
+ DBL_EXP_ADJ, __LDBL_MIN__, LDBL_EXP_ADJ);
+ TESTIT2_I2ALL (scalbn, __FLT_MAX__, -FLT_EXP_ADJ, __DBL_MAX__,
+ -DBL_EXP_ADJ, __LDBL_MAX__, -LDBL_EXP_ADJ);
+ TESTIT2_I2ALL (scalbn, __FLT_MIN__, __FLT_MIN_EXP__, __DBL_MIN__,
+ __DBL_MIN_EXP__, __LDBL_MIN__, __LDBL_MIN_EXP__);
+ TESTIT2_I2ALL (scalbn, __FLT_MAX__, __FLT_MAX_EXP__, __DBL_MAX__,
+ __DBL_MAX_EXP__, __LDBL_MAX__, __LDBL_MAX_EXP__);
+
+ TESTIT2_I2 (scalbln, 1.0, __LONG_MAX__);
+ TESTIT2_I2 (scalbln, 1.0, -__LONG_MAX__-1);
+ TESTIT2_I2 (scalbln, -1.0, __LONG_MAX__);
+ TESTIT2_I2 (scalbln, -1.0, -__LONG_MAX__-1);
+ TESTIT2_I2ALL (scalbln, __FLT_MIN__, FLT_EXP_ADJ, __DBL_MIN__,
+ DBL_EXP_ADJ, __LDBL_MIN__, LDBL_EXP_ADJ);
+ TESTIT2_I2ALL (scalbln, __FLT_MAX__, -FLT_EXP_ADJ, __DBL_MAX__,
+ -DBL_EXP_ADJ, __LDBL_MAX__, -LDBL_EXP_ADJ);
+ TESTIT2_I2ALL (scalbln, __FLT_MIN__, __FLT_MIN_EXP__, __DBL_MIN__,
+ __DBL_MIN_EXP__, __LDBL_MIN__, __LDBL_MIN_EXP__);
+ TESTIT2_I2ALL (scalbln, __FLT_MAX__, __FLT_MAX_EXP__, __DBL_MAX__,
+ __DBL_MAX_EXP__, __LDBL_MAX__, __LDBL_MAX_EXP__);
+
+ TESTIT (logb, 0.0);
+ TESTIT (logb, -0.0);
+
+ TESTIT (ilogb, 0.0);
+ TESTIT (ilogb, -0.0);
+
+#ifndef __SPU__
+ foof (__builtin_ilogbf (__builtin_inff()));
+#endif
+ foo (__builtin_ilogb (__builtin_inf()));
+ fool (__builtin_ilogbl (__builtin_infl()));
+#ifndef __SPU__
+ foof (__builtin_ilogbf (-__builtin_inff()));
+#endif
+ foo (__builtin_ilogb (-__builtin_inf()));
+ fool (__builtin_ilogbl (-__builtin_infl()));
+
+#ifndef __SPU__
+ foof (__builtin_ilogbf (__builtin_nanf("")));
+#endif
+ foo (__builtin_ilogb (__builtin_nan("")));
+ fool (__builtin_ilogbl (__builtin_nanl("")));
+#ifndef __SPU__
+ foof (__builtin_ilogbf (-__builtin_nanf("")));
+#endif
+ foo (__builtin_ilogb (-__builtin_nan("")));
+ fool (__builtin_ilogbl (-__builtin_nanl("")));
+
+ /* The y* arg must be [0 ... Inf] EXclusive. */
+ TESTIT (y0, -1.0);
+ TESTIT (y0, 0.0);
+ TESTIT (y0, -0.0);
+
+ TESTIT (y1, -1.0);
+ TESTIT (y1, 0.0);
+ TESTIT (y1, -0.0);
+
+ TESTIT2_I1 (yn, 2, -1.0);
+ TESTIT2_I1 (yn, 2, 0.0);
+ TESTIT2_I1 (yn, 2, -0.0);
+
+ TESTIT2_I1 (yn, -3, -1.0);
+ TESTIT2_I1 (yn, -3, 0.0);
+ TESTIT2_I1 (yn, -3, -0.0);
+
+ /* The second argument of remquo/remainder/drem must not be 0. */
+ TESTIT_REMQUO (1.0, 0.0);
+ TESTIT_REMQUO (1.0, -0.0);
+ TESTIT2 (remainder, 1.0, 0.0);
+ TESTIT2 (remainder, 1.0, -0.0);
+ TESTIT2 (drem, 1.0, 0.0);
+ TESTIT2 (drem, 1.0, -0.0);
+
+ /* The argument to lgamma* cannot be zero or a negative integer. */
+ TESTIT_REENT (lgamma, -4.0); /* lgamma_r */
+ TESTIT_REENT (lgamma, -3.0); /* lgamma_r */
+ TESTIT_REENT (lgamma, -2.0); /* lgamma_r */
+ TESTIT_REENT (lgamma, -1.0); /* lgamma_r */
+ TESTIT_REENT (lgamma, -0.0); /* lgamma_r */
+ TESTIT_REENT (lgamma, 0.0); /* lgamma_r */
+
+ TESTIT_REENT (gamma, -4.0); /* gamma_r */
+ TESTIT_REENT (gamma, -3.0); /* gamma_r */
+ TESTIT_REENT (gamma, -2.0); /* gamma_r */
+ TESTIT_REENT (gamma, -1.0); /* gamma_r */
+ TESTIT_REENT (gamma, -0.0); /* gamma_r */
+ TESTIT_REENT (gamma, 0.0); /* gamma_r */
+}
+
+/* { dg-final { scan-tree-dump-times "exp2 " 9 "original" } } */
+/* { dg-final { scan-tree-dump-times "exp2f" 9 "original" { target { ! { spu*-*-* } } } } } */
+/* { dg-final { scan-tree-dump-times "exp2f" 6 "original" { target { spu*-*-* } } } } */
+/* { dg-final { scan-tree-dump-times "exp2l" 9 "original" } } */
+/* { dg-final { scan-tree-dump-times "asin " 2 "original" } } */
+/* { dg-final { scan-tree-dump-times "asinf" 2 "original" } } */
+/* { dg-final { scan-tree-dump-times "asinl" 2 "original" } } */
+/* { dg-final { scan-tree-dump-times "acos " 2 "original" } } */
+/* { dg-final { scan-tree-dump-times "acosf" 2 "original" } } */
+/* { dg-final { scan-tree-dump-times "acosl" 2 "original" } } */
+/* { dg-final { scan-tree-dump-times "acosh " 1 "original" } } */
+/* { dg-final { scan-tree-dump-times "acoshf" 1 "original" } } */
+/* { dg-final { scan-tree-dump-times "acoshl" 1 "original" } } */
+/* { dg-final { scan-tree-dump-times "atanh " 2 "original" } } */
+/* { dg-final { scan-tree-dump-times "atanhf" 2 "original" } } */
+/* { dg-final { scan-tree-dump-times "atanhl" 2 "original" } } */
+/* { dg-final { scan-tree-dump-times "log " 3 "original" } } */
+/* { dg-final { scan-tree-dump-times "logf" 3 "original" } } */
+/* { dg-final { scan-tree-dump-times "logl" 3 "original" } } */
+/* { dg-final { scan-tree-dump-times "log2 " 3 "original" } } */
+/* { dg-final { scan-tree-dump-times "log2f" 3 "original" } } */
+/* { dg-final { scan-tree-dump-times "log2l" 3 "original" } } */
+/* { dg-final { scan-tree-dump-times "log10 " 3 "original" } } */
+/* { dg-final { scan-tree-dump-times "log10f" 3 "original" } } */
+/* { dg-final { scan-tree-dump-times "log10l" 3 "original" } } */
+/* { dg-final { scan-tree-dump-times "log1p " 2 "original" } } */
+/* { dg-final { scan-tree-dump-times "log1pf" 2 "original" } } */
+/* { dg-final { scan-tree-dump-times "log1pl" 2 "original" } } */
+/* { dg-final { scan-tree-dump-times "tgamma " 5 "original" } } */
+/* { dg-final { scan-tree-dump-times "tgammaf" 5 "original" } } */
+/* { dg-final { scan-tree-dump-times "tgammal" 5 "original" } } */
+/* { dg-final { scan-tree-dump-times "pow " 13 "original" } } */
+/* { dg-final { scan-tree-dump-times "powf" 13 "original" { target { ! { spu*-*-* } } } } } */
+/* { dg-final { scan-tree-dump-times "powf" 7 "original" { target { spu*-*-* } } } } */
+/* { dg-final { scan-tree-dump-times "powl" 13 "original" } } */
+/* { dg-final { scan-tree-dump-times "sqrt " 1 "original" } } */
+/* { dg-final { scan-tree-dump-times "sqrtf" 1 "original" } } */
+/* { dg-final { scan-tree-dump-times "sqrtl" 1 "original" } } */
+/* { dg-final { scan-tree-dump-times "ldexp " 8 "original" } } */
+/* { dg-final { scan-tree-dump-times "ldexpf" 8 "original" } } */
+/* { dg-final { scan-tree-dump-times "ldexpl" 8 "original" } } */
+/* { dg-final { scan-tree-dump-times "scalbn " 8 "original" } } */
+/* { dg-final { scan-tree-dump-times "scalbnf" 8 "original" } } */
+/* { dg-final { scan-tree-dump-times "scalbnl" 8 "original" } } */
+/* { dg-final { scan-tree-dump-times "scalbln " 8 "original" } } */
+/* { dg-final { scan-tree-dump-times "scalblnf" 8 "original" } } */
+/* { dg-final { scan-tree-dump-times "scalblnl" 8 "original" } } */
+/* { dg-final { scan-tree-dump-times "_logb " 2 "original" } } */
+/* { dg-final { scan-tree-dump-times "_logbf" 2 "original" } } */
+/* { dg-final { scan-tree-dump-times "_logbl" 2 "original" } } */
+/* { dg-final { scan-tree-dump-times "ilogb " 6 "original" } } */
+/* { dg-final { scan-tree-dump-times "ilogbf" 6 "original" { target { ! { spu*-*-* } } } } } */
+/* { dg-final { scan-tree-dump-times "ilogbf" 2 "original" { target { spu*-*-* } } } } */
+/* { dg-final { scan-tree-dump-times "ilogbl" 6 "original" } } */
+/* { dg-final { scan-tree-dump-times "y0 " 3 "original" } } */
+/* { dg-final { scan-tree-dump-times "y0f" 3 "original" } } */
+/* { dg-final { scan-tree-dump-times "y0l" 3 "original" } } */
+/* { dg-final { scan-tree-dump-times "y1 " 3 "original" } } */
+/* { dg-final { scan-tree-dump-times "y1f" 3 "original" } } */
+/* { dg-final { scan-tree-dump-times "y1l" 3 "original" } } */
+/* { dg-final { scan-tree-dump-times "yn " 6 "original" } } */
+/* { dg-final { scan-tree-dump-times "ynf" 6 "original" } } */
+/* { dg-final { scan-tree-dump-times "ynl" 6 "original" } } */
+/* { dg-final { scan-tree-dump-times "remquo " 2 "original" } } */
+/* { dg-final { scan-tree-dump-times "remquof" 2 "original" } } */
+/* { dg-final { scan-tree-dump-times "remquol" 2 "original" } } */
+/* { dg-final { scan-tree-dump-times "remainder " 2 "original" } } */
+/* { dg-final { scan-tree-dump-times "remainderf" 2 "original" } } */
+/* { dg-final { scan-tree-dump-times "remainderl" 2 "original" } } */
+/* { dg-final { scan-tree-dump-times "drem " 2 "original" } } */
+/* { dg-final { scan-tree-dump-times "dremf" 2 "original" } } */
+/* { dg-final { scan-tree-dump-times "dreml" 2 "original" } } */
+/* { dg-final { scan-tree-dump-times "lgamma_r " 6 "original" } } */
+/* { dg-final { scan-tree-dump-times "lgammaf_r" 6 "original" } } */
+/* { dg-final { scan-tree-dump-times "lgammal_r" 6 "original" } } */
+/* { dg-final { scan-tree-dump-times "_gamma_r " 6 "original" } } */
+/* { dg-final { scan-tree-dump-times "_gammaf_r" 6 "original" } } */
+/* { dg-final { scan-tree-dump-times "_gammal_r" 6 "original" } } */
+/* { dg-final { cleanup-tree-dump "original" } } */
diff --git a/gcc/testsuite/gcc.dg/torture/builtin-math-3.c b/gcc/testsuite/gcc.dg/torture/builtin-math-3.c
new file mode 100644
index 000000000..896edccaa
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/builtin-math-3.c
@@ -0,0 +1,374 @@
+/* Copyright (C) 2006 Free Software Foundation.
+
+ Verify that built-in math function constant folding of constant
+ arguments is correctly performed by the compiler.
+
+ Origin: Kaveh R. Ghazi, October 23, 2006. */
+
+/* { dg-do link } */
+
+/* Define "e" with as many bits as found in builtins.c:dconste. */
+#define M_E 2.7182818284590452353602874713526624977572470936999595749669676277241
+
+/* All references to link_error should go away at compile-time. */
+extern void link_error(int);
+
+/* Return TRUE if the sign of X != sign of Y. This is important when
+ comparing signed zeros. */
+#define CKSGN_F(X,Y) \
+ (__builtin_copysignf(1.0F,(X)) != __builtin_copysignf(1.0F,(Y)))
+#define CKSGN(X,Y) \
+ (__builtin_copysign(1.0,(X)) != __builtin_copysign(1.0,(Y)))
+#define CKSGN_L(X,Y) \
+ (__builtin_copysignl(1.0L,(X)) != __builtin_copysignl(1.0L,(Y)))
+
+/* Test that FUNC(ARG) == (RES). */
+#define TESTIT(FUNC,ARG,RES) do { \
+ if (__builtin_##FUNC##f(ARG##F) != RES##F \
+ || CKSGN_F(__builtin_##FUNC##f(ARG##F),RES##F)) \
+ link_error(__LINE__); \
+ if (__builtin_##FUNC(ARG) != RES \
+ || CKSGN(__builtin_##FUNC(ARG),RES)) \
+ link_error(__LINE__); \
+ if (__builtin_##FUNC##l(ARG##L) != RES##L \
+ || CKSGN_L(__builtin_##FUNC##l(ARG##L),RES##L)) \
+ link_error(__LINE__); \
+ } while (0)
+
+/* Range test, check that (LOW) < FUNC(ARG) < (HI). */
+#define TESTIT_R(FUNC,ARG,LOW,HI) do { \
+ if (__builtin_##FUNC##f(ARG) <= (LOW) || __builtin_##FUNC##f(ARG) >= (HI)) \
+ link_error(__LINE__); \
+ if (__builtin_##FUNC(ARG) <= (LOW) || __builtin_##FUNC(ARG) >= (HI)) \
+ link_error(__LINE__); \
+ if (__builtin_##FUNC##l(ARG) <= (LOW) || __builtin_##FUNC##l(ARG) >= (HI)) \
+ link_error(__LINE__); \
+ } while (0)
+
+/* Test that FUNC(ARG1, ARG2) == (RES). */
+#define TESTIT2(FUNC,ARG1,ARG2,RES) do { \
+ if (__builtin_##FUNC##f(ARG1##F, ARG2##F) != RES##F \
+ || CKSGN_F(__builtin_##FUNC##f(ARG1##F,ARG2##F),RES##F)) \
+ link_error(__LINE__); \
+ if (__builtin_##FUNC(ARG1, ARG2) != RES \
+ || CKSGN(__builtin_##FUNC(ARG1,ARG2),RES)) \
+ link_error(__LINE__); \
+ if (__builtin_##FUNC##l(ARG1##L, ARG2##L) != RES##L \
+ || CKSGN_L(__builtin_##FUNC##l(ARG1##L,ARG2##L),RES##L)) \
+ link_error(__LINE__); \
+ } while (0)
+
+/* Range test, check that (LOW) < FUNC(ARG1,ARG2) < (HI). */
+#define TESTIT2_R(FUNC,ARG1,ARG2,LOW,HI) do { \
+ if (__builtin_##FUNC##f(ARG1, ARG2) <= (LOW) \
+ || __builtin_##FUNC##f(ARG1, ARG2) >= (HI)) \
+ link_error(__LINE__); \
+ if (__builtin_##FUNC(ARG1, ARG2) <= (LOW) \
+ || __builtin_##FUNC(ARG1, ARG2) >= (HI)) \
+ link_error(__LINE__); \
+ if (__builtin_##FUNC##l(ARG1, ARG2) <= (LOW) \
+ || __builtin_##FUNC##l(ARG1, ARG2) >= (HI)) \
+ link_error(__LINE__); \
+ } while (0)
+
+/* Test that FUNC(ARG1, ARG2, ARG3) == (RES). */
+#define TESTIT3(FUNC,ARG1,ARG2,ARG3,RES) do { \
+ if (__builtin_##FUNC##f(ARG1##F, ARG2##F, ARG3##F) != RES##F \
+ || CKSGN_F(__builtin_##FUNC##f(ARG1##F,ARG2##F,ARG3##F),RES##F)) \
+ link_error(__LINE__); \
+ if (__builtin_##FUNC(ARG1, ARG2, ARG3) != RES \
+ || CKSGN(__builtin_##FUNC(ARG1,ARG2,ARG3),RES)) \
+ link_error(__LINE__); \
+ if (__builtin_##FUNC##l(ARG1##L, ARG2##L, ARG3##L) != RES##L \
+ || CKSGN_L(__builtin_##FUNC##l(ARG1##L,ARG2##L,ARG3##L),RES##L)) \
+ link_error(__LINE__); \
+ } while (0)
+
+/* Test that for FUNC(ARG, &ARG_S, &ARG_C);
+ assert (ARG_S == RES_S && ARG_C == RES_C);. */
+#define TESTIT_2P(FUNC,ARG,ARG_S,ARG_C,RES_S,RES_C) do { \
+ __builtin_##FUNC##f(ARG##F, &ARG_S##f, &ARG_C##f); \
+ if (ARG_S##f != (RES_S##F) || ARG_C##f != (RES_C##F)) \
+ link_error(__LINE__); \
+ __builtin_##FUNC(ARG, &ARG_S, &ARG_C); \
+ if (ARG_S != (RES_S) || ARG_C != (RES_C)) \
+ link_error(__LINE__); \
+ __builtin_##FUNC##l(ARG##L, &ARG_S##l, &ARG_C##l); \
+ if (ARG_S##l != (RES_S##L) || ARG_C##l != (RES_C##L)) \
+ link_error(__LINE__); \
+ } while (0)
+
+/* Test that for FUNC(ARG, &ARG_S, &ARG_C);
+ assert (LOW_S < ARG_S < HI_S && LOW_C < ARG_C < HI_C);. */
+#define TESTIT_2P_R(FUNC,ARG,ARG_S,ARG_C,LOW_S,HI_S,LOW_C,HI_C) do { \
+ __builtin_##FUNC##f(ARG##F, &ARG_S##f, &ARG_C##f); \
+ if (ARG_S##f <= (LOW_S##F) || ARG_S##f >= (HI_S##F) \
+ || ARG_C##f <= (LOW_C##F) || ARG_C##f >= (HI_C##F)) \
+ link_error(__LINE__); \
+ __builtin_##FUNC(ARG, &ARG_S, &ARG_C); \
+ if (ARG_S <= (LOW_S) || ARG_S >= (HI_S) \
+ || ARG_C <= (LOW_C) || ARG_C >= (HI_C)) \
+ link_error(__LINE__); \
+ __builtin_##FUNC##l(ARG##L, &ARG_S##l, &ARG_C##l); \
+ if (ARG_S##l <= (LOW_S##L) || ARG_S##l >= (HI_S##L) \
+ || ARG_C##l <= (LOW_C##L) || ARG_C##l >= (HI_C##L)) \
+ link_error(__LINE__); \
+ } while (0)
+
+int main (void)
+{
+#ifdef __OPTIMIZE__
+ float sf, cf, oneF = 1.0F;
+ double s, c, one = 1.0;
+ long double sl, cl, oneL = 1.0L;
+#endif
+
+ TESTIT_R (asin, -1.0, -3.15/2.0, -3.14/2.0); /* asin(-1) == -pi/2 */
+ TESTIT (asin, 0.0, 0.0); /* asin(0) == 0 */
+ TESTIT (asin, -0.0, -0.0); /* asin(-0) == -0 */
+ TESTIT_R (asin, 1.0, 3.14/2.0, 3.15/2.0); /* asin(1) == pi/2 */
+
+ TESTIT_R (acos, -1.0, 3.14, 3.15); /* acos(-1) == pi */
+ TESTIT_R (acos, 0.0, 3.14/2.0, 3.15/2.0); /* acos(0) == pi/2 */
+ TESTIT_R (acos, -0.0, 3.14/2.0, 3.15/2.0); /* acos(-0) == pi/2 */
+ TESTIT (acos, 1.0, 0.0); /* acos(1) == 0 */
+
+ TESTIT_R (atan, -1.0, -3.15/4.0, -3.14/4.0); /* atan(-1) == -pi/4 */
+ TESTIT (atan, 0.0, 0.0); /* atan(0) == 0 */
+ TESTIT (atan, -0.0, -0.0); /* atan(-0) == -0 */
+ TESTIT_R (atan, 1.0, 3.14/4.0, 3.15/4.0); /* atan(1) == pi/4 */
+
+ TESTIT_R (asinh, -1.0, -0.89, -0.88); /* asinh(-1) == -0.881... */
+ TESTIT (asinh, 0.0, 0.0); /* asinh(0) == 0 */
+ TESTIT (asinh, -0.0, -0.0); /* asinh(-0) == -0 */
+ TESTIT_R (asinh, 1.0, 0.88, 0.89); /* asinh(1) == 0.881... */
+
+ TESTIT (acosh, 1.0, 0.0); /* acosh(1) == 0. */
+ TESTIT_R (acosh, 2.0, 1.31, 1.32); /* acosh(2) == 1.316... */
+
+ TESTIT_R (atanh, -0.5, -0.55, -0.54); /* atanh(-0.5) == -0.549... */
+ TESTIT (atanh, 0.0, 0.0); /* atanh(0) == 0 */
+ TESTIT (atanh, -0.0, -0.0); /* atanh(-0) == -0 */
+ TESTIT_R (atanh, 0.5, 0.54, 0.55); /* atanh(0.5) == 0.549... */
+
+ TESTIT_R (sin, -1.0, -0.85, -0.84); /* sin(-1) == -0.841... */
+ TESTIT (sin, 0.0, 0.0); /* sin(0) == 0 */
+ TESTIT (sin, -0.0, -0.0); /* sin(-0) == -0 */
+ TESTIT_R (sin, 1.0, 0.84, 0.85); /* sin(1) == 0.841... */
+
+ TESTIT_R (cos, -1.0, 0.54, 0.55); /* cos(-1) == 0.5403... */
+ TESTIT (cos, 0.0, 1.0); /* cos(0) == 1 */
+ TESTIT (cos, -0.0, 1.0); /* cos(-0) == 1 */
+ TESTIT_R (cos, 1.0, 0.54, 0.55); /* cos(1) == 0.5403... */
+
+ TESTIT_R (tan, -1.0, -1.56, 1.55); /* tan(-1) == -1.557... */
+ TESTIT (tan, 0.0, 0.0); /* tan(0) == 0 */
+ TESTIT (tan, -0.0, -0.0); /* tan(-0) == -0 */
+ TESTIT_R (tan, 1.0, 1.55, 1.56); /* tan(1) == 1.557... */
+
+#ifdef __OPTIMIZE__
+ /* These tests rely on propagating the variables s, c and one, which
+ happens only when optimization is turned on. */
+ TESTIT_2P_R (sincos, -1.0, s, c, -0.85, -0.84, 0.54, 0.55); /* (s==-0.841..., c==0.5403...) */
+ TESTIT_2P (sincos, 0.0, s, c, 0.0, 1.0); /* (s==0, c==1) */
+ TESTIT_2P (sincos, -0.0, s, c, -0.0, 1.0); /* (s==-0, c==1) */
+ TESTIT_2P_R (sincos, 1.0, s, c, 0.84, 0.85, 0.54, 0.55); /* (s==0.841..., c==0.5403...) */
+ TESTIT_2P_R (sincos, one, s, c, 0.84, 0.85, 0.54, 0.55); /* (s==0.841..., c==0.5403...) */
+ TESTIT_2P_R (sincos, -one, s, c, -0.85, -0.84, 0.54, 0.55); /* (s==-0.841..., c==0.5403...) */
+#endif
+
+ TESTIT_R (sinh, -1.0, -1.18, -1.17); /* sinh(-1) == -1.175... */
+ TESTIT (sinh, 0.0, 0.0); /* sinh(0) == 0 */
+ TESTIT (sinh, -0.0, -0.0); /* sinh(-0) == -0 */
+ TESTIT_R (sinh, 1.0, 1.17, 1.18); /* sinh(1) == 1.175... */
+
+ TESTIT_R (cosh, -1.0, 1.54, 1.55); /* cosh(-1) == 1.543... */
+ TESTIT (cosh, 0.0, 1.0); /* cosh(0) == 1 */
+ TESTIT (cosh, -0.0, 1.0); /* cosh(-0) == 1 */
+ TESTIT_R (cosh, 1.0, 1.54, 1.55); /* cosh(1) == 1.543... */
+
+ TESTIT_R (tanh, -1.0, -0.77, -0.76); /* tanh(-1) == -0.761... */
+ TESTIT (tanh, -0.0, -0.0); /* tanh(-0) == -0 */
+ TESTIT (tanh, 0.0, 0.0); /* tanh(0) == 0 */
+ TESTIT_R (tanh, 1.0, 0.76, 0.77); /* tanh(1) == 0.761... */
+
+ TESTIT_R (exp, -1.0, 0.36, 0.37); /* exp(-1) == 1/e */
+ TESTIT (exp, -0.0, 1.0); /* exp(-0) == 1 */
+ TESTIT (exp, 0.0, 1.0); /* exp(0) == 1 */
+ TESTIT_R (exp, 1.0, 2.71, 2.72); /* exp(1) == e */
+
+ TESTIT (exp2, -1.0, 0.5); /* exp2(-1) == 1/2 */
+ TESTIT (exp2, -0.0, 1.0); /* exp2(-0) == 1 */
+ TESTIT (exp2, 0.0, 1.0); /* exp2(0) == 1 */
+ TESTIT (exp2, 1.0, 2.0); /* exp2(1) == 2 */
+
+ TESTIT (exp10, -1.0, 0.1); /* exp10(-1) == 1/10 */
+ TESTIT (exp10, -0.0, 1.0); /* exp10(-0) == 1 */
+ TESTIT (exp10, 0.0, 1.0); /* exp10(0) == 1 */
+ TESTIT (exp10, 1.0, 10.0); /* exp10(1) == 10 */
+
+ TESTIT (pow10, -1.0, 0.1); /* pow10(-1) == 1/10 */
+ TESTIT (pow10, -0.0, 1.0); /* pow10(-0) == 1 */
+ TESTIT (pow10, 0.0, 1.0); /* pow10(0) == 1 */
+ TESTIT (pow10, 1.0, 10.0); /* pow10(1) == 10 */
+
+ TESTIT_R (expm1, -1.0, -0.64, -0.63); /* expm1(-1) == 1/e - 1 */
+ TESTIT (expm1, -0.0, -0.0); /* expm1(-0) == 0 */
+ TESTIT (expm1, 0.0, 0.0); /* expm1(0) == 0 */
+ TESTIT_R (expm1, 1.0, 1.71, 1.72); /* expm1(1) == e - 1 */
+
+ TESTIT (log, 1.0, 0.0); /* log(1) == 0 */
+ TESTIT_R (log, M_E, 0.99, 1.01); /* log(e) == 1.000... */
+ TESTIT_R (log, M_E*M_E, 1.99, 2.01); /* log(e*e) == 2.000... */
+
+ TESTIT (log2, 1.0, 0.0); /* log2(1) == 0 */
+ TESTIT (log2, 2.0, 1.0); /* log2(2) == 1 */
+ TESTIT (log2, 4.0, 2.0); /* log2(4) == 2 */
+
+ TESTIT (log10, 1.0, 0.0); /* log10(1) == 0 */
+ TESTIT (log10, 10.0, 1.0); /* log10(10) == 1 */
+ TESTIT (log10, 100.0, 2.0); /* log10(100) == 2 */
+
+ TESTIT (log1p, 0.0, 0.0); /* log1p(0) == 0 */
+ TESTIT (log1p, -0.0, -0.0); /* log1p(-0) == -0 */
+ TESTIT_R (log1p, M_E-1, 0.99, 1.01); /* log1p(e-1) == 1.000... */
+ TESTIT_R (log1p, M_E*M_E-1, 1.99, 2.01); /* log1p(e*e-1) == 2.000... */
+
+ TESTIT (cbrt, -0.0, -0.0); /* cbrt(-0) == -0 */
+ TESTIT (cbrt, 0.0, 0.0); /* cbrt(0) == 0 */
+ TESTIT (cbrt, 1.0, 1.0); /* cbrt(1) == 1 */
+ TESTIT (cbrt, -1.0, -1.0); /* cbrt(-1) == -1 */
+ TESTIT (cbrt, 8.0, 2.0); /* cbrt(8) == 2 */
+ TESTIT (cbrt, -8.0, -2.0); /* cbrt(-8) == -2 */
+
+ TESTIT (erf, -0.0, -0.0); /* erf(-0) == -0 */
+ TESTIT (erf, 0.0, 0.0); /* erf(0) == 0 */
+ TESTIT_R (erf, 1.0, 0.84, 0.85); /* erf(1) == 0.842... */
+ TESTIT_R (erf, -1.0, -0.85, -0.84); /* erf(-1) == -0.842... */
+
+ TESTIT (erfc, -0.0, 1.0); /* erfc(-0) == 1 */
+ TESTIT (erfc, 0.0, 1.0); /* erfc(0) == 1 */
+ TESTIT_R (erfc, 1.0, 0.15, 0.16); /* erfc(1) == 0.157... */
+ TESTIT_R (erfc, -1.0, 1.84, 1.85); /* erfc(-1) == 1.842... */
+
+ TESTIT_R (tgamma, -4.5, -0.061, -0.060); /* tgamma(-4.5) == -0.06001... */
+ TESTIT_R (tgamma, -3.5, 0.27, 0.28); /* tgamma(-3.5) == 0.27008... */
+ TESTIT_R (tgamma, -2.5, -0.95, -0.94); /* tgamma(-2.5) == -0.945... */
+ TESTIT_R (tgamma, -1.5, 2.36, 2.37); /* tgamma(-1.5) == 2.363... */
+ TESTIT_R (tgamma, -0.5, -3.55, -3.54); /* tgamma(-0.5) == -3.544... */
+ TESTIT_R (tgamma, 0.5, 1.77, 1.78); /* tgamma(0.5) == 1.772... */
+ TESTIT (tgamma, 1.0, 1.0); /* tgamma(1) == 1 */
+ TESTIT_R (tgamma, 1.5, 0.88, 0.89); /* tgamma(1.5) == 0.886... */
+ TESTIT (tgamma, 2.0, 1.0); /* tgamma(2) == 1 */
+ TESTIT_R (tgamma, 2.5, 1.32, 1.33); /* tgamma(2.5) == 1.329... */
+ TESTIT (tgamma, 3.0, 2.0); /* tgamma(3) == 2 */
+ TESTIT_R (tgamma, 3.5, 3.32, 3.33); /* tgamma(3.5) == 3.323... */
+ TESTIT (tgamma, 4.0, 6.0); /* tgamma(4) == 6 */
+ TESTIT_R (tgamma, 4.5, 11.63, 11.64); /* tgamma(4.5) == 11.631... */
+
+ TESTIT2 (pow, 3.0, 4.0, 81.0); /* pow(3,4) == 81 */
+ TESTIT2 (pow, -3.0, 5.0, -243.0); /* pow(-3,5) == -243 */
+ TESTIT2 (pow, 16.0, 0.25, 2.0); /* pow(16,1/4) == 2 */
+ TESTIT2 (pow, 4.0, -2.0, 0.0625); /* pow(4,-2) == 1/16 */
+ TESTIT2 (pow, -2.0, -3.0, -0.125); /* pow(-2,-3) == -1/8 */
+ TESTIT2_R (pow, -1.5, -3.0, -0.297, -0.296); /* pow(-1.5,-3) == -1/3.375 */
+
+ TESTIT2 (hypot, 0.0, 0.0, 0.0); /* hypot(0,0) == 0 */
+ TESTIT2 (hypot, -0.0, 0.0, 0.0); /* hypot(-0,0) == 0 */
+ TESTIT2 (hypot, 0.0, -0.0, 0.0); /* hypot(0,-0) == 0 */
+ TESTIT2 (hypot, -0.0, -0.0, 0.0); /* hypot(-0,-0) == 0 */
+ TESTIT2 (hypot, 3.0, 4.0, 5.0); /* hypot(3,4) == 5 */
+ TESTIT2 (hypot, -3.0, 4.0, 5.0); /* hypot(-3,4) == 5 */
+ TESTIT2 (hypot, 3.0, -4.0, 5.0); /* hypot(3,-4) == 5 */
+ TESTIT2 (hypot, -3.0, -4.0, 5.0); /* hypot(-3,-4) == 5 */
+ TESTIT2_R (hypot, 4.0, 5.0, 6.40, 6.41); /* hypot(4,5) == 6.403... */
+
+ TESTIT2 (atan2, 0.0, 0.0, 0.0); /* atan2(0,0) == 0 */
+ TESTIT2 (atan2, -0.0, 0.0, -0.0); /* atan2(-0,0) == -0 */
+ TESTIT2_R (atan2, 0.0, -0.0, 3.14, 3.15); /* atan2(0,-0) == pi */
+ TESTIT2_R (atan2, -0.0, -0.0, -3.15, -3.14); /* atan2(-0,-0) == -pi */
+ TESTIT2_R (atan2, 0.0, -1.0, 3.14, 3.15); /* atan2(0,-1) == pi */
+ TESTIT2_R (atan2, -0.0, -1.0, -3.15, -3.14); /* atan2(-0,-1) == -pi */
+ TESTIT2 (atan2, 0.0, 1.0, 0.0); /* atan2(0,1) == 0 */
+ TESTIT2 (atan2, -0.0, 1.0, -0.0); /* atan2(-0,1) == -0 */
+ TESTIT2_R (atan2, -1.0, 0.0, -1.58, -1.57); /* atan2(-1,0) == -pi/2 */
+ TESTIT2_R (atan2, 1.0, 0.0, 1.57, 1.58); /* atan2(1,0) == pi/2 */
+
+ TESTIT2 (fdim, 0.0, 0.0, 0.0); /* fdim(0,0) == 0 */
+ TESTIT2 (fdim, -0.0, 0.0, 0.0); /* fdim(-0,0) == 0 */
+ TESTIT2 (fdim, 0.0, -0.0, 0.0); /* fdim(0,-0) == 0 */
+ TESTIT2 (fdim, -0.0, -0.0, 0.0); /* fdim(-0,-0) == 0 */
+ TESTIT2 (fdim, 5.0, 5.0, 0.0); /* fdim(5,5) == 0 */
+ TESTIT2 (fdim, 5.0, 6.0, 0.0); /* fdim(5,6) == 0 */
+ TESTIT2 (fdim, 6.0, 5.0, 1.0); /* fdim(6,5) == 1 */
+ TESTIT2 (fdim, -5.0, -6.0, 1.0); /* fdim(-5,-6) == 1 */
+ TESTIT2 (fdim, -6.0, -5.0, 0.0); /* fdim(-6,-5) == 0 */
+
+ TESTIT2 (fmin, 5.0, 6.0, 5.0); /* fmin(5,6) == 5 */
+ TESTIT2 (fmin, 6.0, 5.0, 5.0); /* fmin(6,5) == 5 */
+ TESTIT2 (fmin, -5.0, -6.0, -6.0); /* fmin(-5,-6) == -6 */
+ TESTIT2 (fmin, -6.0, -5.0, -6.0); /* fmin(-6,-5) == -6 */
+ TESTIT2 (fmin, -0.0, 0.0, -0.0); /* fmin(-0,0) == -0 */
+ TESTIT2 (fmin, 0.0, -0.0, -0.0); /* fmin(-0,0) == -0 */
+
+ TESTIT2 (fmax, 5.0, 6.0, 6.0); /* fmax(5,6) == 6 */
+ TESTIT2 (fmax, 6.0, 5.0, 6.0); /* fmax(6,5) == 6 */
+ TESTIT2 (fmax, -5.0, -6.0, -5.0); /* fmax(-5,-6) == -5 */
+ TESTIT2 (fmax, -6.0, -5.0, -5.0); /* fmax(-6,-5) == -5 */
+ TESTIT2 (fmax, -0.0, 0.0, 0.0); /* fmax(-0,0) == 0 */
+ TESTIT2 (fmax, 0.0, -0.0, 0.0); /* fmax(-0,0) == 0 */
+
+ TESTIT3 (fma, 2.0, 3.0, 4.0, 10.0); /* fma(2,3,4) == 10 */
+ TESTIT3 (fma, 2.0, -3.0, 4.0, -2.0); /* fma(2,-3,4) == -2 */
+ TESTIT3 (fma, 2.0, 3.0, -4.0, 2.0); /* fma(2,3,-4) == 2 */
+ TESTIT3 (fma, 2.0, -3.0, -4.0, -10.0); /* fma(2,-3,-4) == -10 */
+ TESTIT3 (fma, -2.0, -3.0, -4.0, 2.0); /* fma(-2,-3,-4) == 2 */
+ TESTIT3 (fma, 6.0, -0.0, 0.0, 0.0); /* fma(6,-0,0) == 0 */
+ TESTIT3 (fma, -0.0, 6.0, 0.0, 0.0); /* fma(-0,6,0) == 0 */
+ TESTIT3 (fma, 6.0, -0.0, -0.0, -0.0); /* fma(6,-0,-0) == -0 */
+ TESTIT3 (fma, -0.0, 6.0, -0.0, -0.0); /* fma(-0,6,-0) == -0 */
+ TESTIT3 (fma, 0.0, 0.0, 0.0, 0.0); /* fma(0,0,0) == 0 */
+ TESTIT3 (fma, -0.0, 0.0, 0.0, 0.0); /* fma(-0,0,0) == 0 */
+ TESTIT3 (fma, 0.0, -0.0, 0.0, 0.0); /* fma(0,-0,0) == 0 */
+ TESTIT3 (fma, -0.0, -0.0, 0.0, 0.0); /* fma(-0,-0,0) == 0 */
+ TESTIT3 (fma, 0.0, 0.0, -0.0, 0.0); /* fma(0,0,-0) == 0 */
+ TESTIT3 (fma, -0.0, 0.0, -0.0, -0.0); /* fma(-0,0,-0) == -0 */
+ TESTIT3 (fma, 0.0, -0.0, -0.0, -0.0); /* fma(0,-0,-0) == -0 */
+ TESTIT3 (fma, -0.0, -0.0, -0.0, 0.0); /* fma(-0,-0,-0) == 0 */
+
+ if (__builtin_fmaf(__FLT_MAX__, 2.0F, -__FLT_MAX__) != __FLT_MAX__)
+ link_error (__LINE__);
+ if (__builtin_fmaf(2.0F,__FLT_MAX__, -__FLT_MAX__) != __FLT_MAX__)
+ link_error (__LINE__);
+ if (__builtin_fmaf(__FLT_MIN__, 0.5F, __FLT_MIN__) != __FLT_MIN__*1.5F)
+ link_error (__LINE__);
+ if (__builtin_fmaf(0.5F,__FLT_MIN__, __FLT_MIN__) != __FLT_MIN__*1.5F)
+ link_error (__LINE__);
+
+ if (__builtin_fma(__DBL_MAX__, 2.0, -__DBL_MAX__) != __DBL_MAX__)
+ link_error (__LINE__);
+ if (__builtin_fma(2.0,__DBL_MAX__, -__DBL_MAX__) != __DBL_MAX__)
+ link_error (__LINE__);
+ if (__builtin_fma(__DBL_MIN__, 0.5, __DBL_MIN__) != __DBL_MIN__*1.5)
+ link_error (__LINE__);
+ if (__builtin_fma(0.5,__DBL_MIN__, __DBL_MIN__) != __DBL_MIN__*1.5)
+ link_error (__LINE__);
+
+ if (__builtin_fmal(__LDBL_MAX__, 2.0L, -__LDBL_MAX__) != __LDBL_MAX__)
+ link_error (__LINE__);
+ if (__builtin_fmal(2.0L,__LDBL_MAX__, -__LDBL_MAX__) != __LDBL_MAX__)
+ link_error (__LINE__);
+ if (__builtin_fmal(__LDBL_MIN__, 0.5L, __LDBL_MIN__) != __LDBL_MIN__*1.5L)
+ link_error (__LINE__);
+ if (__builtin_fmal(0.5L,__LDBL_MIN__, __LDBL_MIN__) != __LDBL_MIN__*1.5L)
+ link_error (__LINE__);
+
+ TESTIT (sqrt, -0.0, -0.0); /* sqrt(-0) == -0 */
+ TESTIT (sqrt, 0.0, 0.0); /* sqrt(0) == 0 */
+ TESTIT (sqrt, 1.0, 1.0); /* sqrt(1) == 1 */
+ TESTIT (sqrt, 4.0, 2.0); /* sqrt(4) == 2 */
+ TESTIT_R (sqrt, 1.5, 1.22, 1.23); /* sqrt(1.5) == 1.224... */
+ TESTIT_R (sqrt, 2.0, 1.41, 1.42); /* sqrt(2) == 1.414... */
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/builtin-math-4.c b/gcc/testsuite/gcc.dg/torture/builtin-math-4.c
new file mode 100644
index 000000000..d47e13933
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/builtin-math-4.c
@@ -0,0 +1,311 @@
+/* Copyright (C) 2007 Free Software Foundation.
+
+ Verify that built-in math function constant folding of constant
+ arguments is correctly performed by the compiler. This testcase is
+ for functionality that was available as of mpfr-2.3.0.
+
+ Origin: Kaveh R. Ghazi, April 23, 2007. */
+
+/* { dg-do link } */
+
+/* All references to link_error should go away at compile-time. */
+extern void link_error(int);
+
+/* Return TRUE if the sign of X != sign of Y. This is important when
+ comparing signed zeros. */
+#define CKSGN_F(X,Y) \
+ (__builtin_copysignf(1.0F,(X)) != __builtin_copysignf(1.0F,(Y)))
+#define CKSGN(X,Y) \
+ (__builtin_copysign(1.0,(X)) != __builtin_copysign(1.0,(Y)))
+#define CKSGN_L(X,Y) \
+ (__builtin_copysignl(1.0L,(X)) != __builtin_copysignl(1.0L,(Y)))
+
+/* Test that FUNC(ARG) == (RES). */
+#define TESTIT(FUNC,ARG,RES) do { \
+ if (__builtin_##FUNC##f(ARG##F) != RES##F \
+ || CKSGN_F(__builtin_##FUNC##f(ARG##F),RES##F)) \
+ link_error(__LINE__); \
+ if (__builtin_##FUNC(ARG) != RES \
+ || CKSGN(__builtin_##FUNC(ARG),RES)) \
+ link_error(__LINE__); \
+ if (__builtin_##FUNC##l(ARG##L) != RES##L \
+ || CKSGN_L(__builtin_##FUNC##l(ARG##L),RES##L)) \
+ link_error(__LINE__); \
+ } while (0)
+
+/* Range test, check that (LOW) < FUNC(ARG) < (HI). */
+#define TESTIT_R(FUNC,ARG,LOW,HI) do { \
+ if (__builtin_##FUNC##f(ARG) <= (LOW) || __builtin_##FUNC##f(ARG) >= (HI)) \
+ link_error(__LINE__); \
+ if (__builtin_##FUNC(ARG) <= (LOW) || __builtin_##FUNC(ARG) >= (HI)) \
+ link_error(__LINE__); \
+ if (__builtin_##FUNC##l(ARG) <= (LOW) || __builtin_##FUNC##l(ARG) >= (HI)) \
+ link_error(__LINE__); \
+ } while (0)
+
+/* Test that FUNC(ARG1, ARG2) == (RES). */
+#define TESTIT2(FUNC,ARG1,ARG2,RES) do { \
+ if (__builtin_##FUNC##f(ARG1, ARG2##F) != RES##F \
+ || CKSGN_F(__builtin_##FUNC##f(ARG1,ARG2##F),RES##F)) \
+ link_error(__LINE__); \
+ if (__builtin_##FUNC(ARG1, ARG2) != RES \
+ || CKSGN(__builtin_##FUNC(ARG1,ARG2),RES)) \
+ link_error(__LINE__); \
+ if (__builtin_##FUNC##l(ARG1, ARG2##L) != RES##L \
+ || CKSGN_L(__builtin_##FUNC##l(ARG1,ARG2##L),RES##L)) \
+ link_error(__LINE__); \
+ } while (0)
+
+/* Range test, check that (LOW) < FUNC(ARG1,ARG2) < (HI). */
+#define TESTIT2_R(FUNC,ARG1,ARG2,LOW,HI) do { \
+ if (__builtin_##FUNC##f(ARG1, ARG2##F) <= (LOW) \
+ || __builtin_##FUNC##f(ARG1, ARG2##F) >= (HI)) \
+ link_error(__LINE__); \
+ if (__builtin_##FUNC(ARG1, ARG2) <= (LOW) \
+ || __builtin_##FUNC(ARG1, ARG2) >= (HI)) \
+ link_error(__LINE__); \
+ if (__builtin_##FUNC##l(ARG1, ARG2##L) <= (LOW) \
+ || __builtin_##FUNC##l(ARG1, ARG2##L) >= (HI)) \
+ link_error(__LINE__); \
+ } while (0)
+
+/* Test that remquo(ARG0, ARG1, &ARG_Q) == RES and ARG_Q == RES_Q.
+ Also test remainder/drem (ARG0,ARG1) == RES. */
+#define TESTIT2_REMQUO(ARG0,ARG1,ARG_Q,RES,RES_Q) do { \
+ ARG_Q = 12345; \
+ if (__builtin_remquof(ARG0##F, ARG1##F, &ARG_Q) != RES##F \
+ || CKSGN_F(__builtin_remquof(ARG0##F, ARG1##F, &ARG_Q),RES##F) \
+ || ARG_Q != RES_Q \
+ || __builtin_remainderf(ARG0##F, ARG1##F) != RES##F \
+ || CKSGN_F(__builtin_remainderf(ARG0##F, ARG1##F),RES##F) \
+ || __builtin_dremf(ARG0##F, ARG1##F) != RES##F \
+ || CKSGN_F(__builtin_dremf(ARG0##F, ARG1##F),RES##F)) \
+ link_error(__LINE__); \
+ ARG_Q = 12345; \
+ if (__builtin_remquo(ARG0, ARG1, &ARG_Q) != RES \
+ || CKSGN(__builtin_remquo(ARG0, ARG1, &ARG_Q),RES) \
+ || ARG_Q != RES_Q \
+ || __builtin_remainder(ARG0, ARG1) != RES \
+ || CKSGN(__builtin_remainder(ARG0, ARG1),RES) \
+ || __builtin_drem(ARG0, ARG1) != RES \
+ || CKSGN(__builtin_drem(ARG0, ARG1),RES)) \
+ link_error(__LINE__); \
+ ARG_Q = 12345; \
+ if (__builtin_remquol(ARG0##L, ARG1##L, &ARG_Q) != RES##L \
+ || CKSGN_L(__builtin_remquol(ARG0##L, ARG1##L, &ARG_Q),RES##L) \
+ || ARG_Q != RES_Q \
+ || __builtin_remainderl(ARG0##L, ARG1##L) != RES##L \
+ || CKSGN_L(__builtin_remainderl(ARG0##L, ARG1##L),RES##L) \
+ || __builtin_dreml(ARG0##L, ARG1##L) != RES##L \
+ || CKSGN_L(__builtin_dreml(ARG0##L, ARG1##L),RES##L)) \
+ link_error(__LINE__); \
+ } while (0)
+
+/* Test that FUNC(ARG,&SG) == (RES) && SG == RES_SG. */
+#define TESTIT_LGAMMA_REENT(FUNC,ARG,RES,RES_SG) do { \
+ int sg; \
+ sg = 123; \
+ if (__builtin_##FUNC##f_r(ARG##F,&sg) != RES##F \
+ || sg != RES_SG \
+ || CKSGN_F(__builtin_##FUNC##f_r(ARG##F,&sg),RES##F)) \
+ link_error(__LINE__); \
+ sg = 123; \
+ if (__builtin_##FUNC##_r(ARG,&sg) != RES \
+ || sg != RES_SG \
+ || CKSGN(__builtin_##FUNC##_r(ARG,&sg),RES)) \
+ link_error(__LINE__); \
+ sg = 123; \
+ if (__builtin_##FUNC##l_r(ARG##L,&sg) != RES##L \
+ || sg != RES_SG \
+ || CKSGN_L(__builtin_##FUNC##l_r(ARG##L,&sg),RES##L)) \
+ link_error(__LINE__); \
+ } while (0)
+
+/* Range test, check that (LOW) < FUNC(ARG,&SG) < (HI), and also test
+ that SG == RES_SG. */
+#define TESTIT_LGAMMA_REENT_R(FUNC,ARG,LOW,HI,RES_SG) do { \
+ int sg; \
+ sg = 123; \
+ if (__builtin_##FUNC##f_r(ARG,&sg) <= (LOW) || __builtin_##FUNC##f_r(ARG,&sg) >= (HI) \
+ || sg != RES_SG) \
+ link_error(__LINE__); \
+ sg = 123; \
+ if (__builtin_##FUNC##_r(ARG,&sg) <= (LOW) || __builtin_##FUNC##_r(ARG,&sg) >= (HI) \
+ || sg != RES_SG) \
+ link_error(__LINE__); \
+ sg = 123; \
+ if (__builtin_##FUNC##l_r(ARG,&sg) <= (LOW) || __builtin_##FUNC##l_r(ARG,&sg) >= (HI) \
+ || sg != RES_SG) \
+ link_error(__LINE__); \
+ } while (0)
+
+int main (void)
+{
+#ifdef __OPTIMIZE__
+ int q;
+#endif
+
+ TESTIT (j0, 0.0, 1.0); /* j0(0) == 1 */
+ TESTIT (j0, -0.0, 1.0); /* j0(-0) == 1 */
+ TESTIT_R (j0, 1.0, 0.765, 0.766); /* j0(1) == 0.7651... */
+ TESTIT_R (j0, -1.0, 0.765, 0.766); /* j0(-1) == 0.7651... */
+
+ TESTIT (j1, 0.0, 0.0); /* j1(0) == 0 */
+ TESTIT (j1, -0.0, -0.0); /* j1(-0) == -0 */
+ TESTIT_R (j1, 1.0, 0.44, 0.45); /* j1(1) == 0.440... */
+ TESTIT_R (j1, -1.0, -0.45, -0.44); /* j1(-1) == -0.440... */
+
+ TESTIT2 (jn, 5, 0.0, 0.0); /* jn(5,0) == 0 */
+ TESTIT2 (jn, 5, -0.0, -0.0); /* jn(5,-0) == -0 */
+ TESTIT2 (jn, 6, 0.0, 0.0); /* jn(6,0) == 0 */
+ TESTIT2 (jn, 6, -0.0, 0.0); /* jn(6,-0) == 0 */
+
+ TESTIT2 (jn, -5, 0.0, -0.0); /* jn(-5,0) == -0 */
+ TESTIT2 (jn, -5, -0.0, 0.0); /* jn(-5,-0) == 0 */
+ TESTIT2 (jn, -6, 0.0, 0.0); /* jn(-6,0) == 0 */
+ TESTIT2 (jn, -6, -0.0, 0.0); /* jn(-6,-0) == 0 */
+
+ TESTIT2_R (jn, 2, 1.0, 0.11, 0.12); /* jn(2,1) == 0.114... */
+ TESTIT2_R (jn, 2, -1.0, 0.11, 0.12); /* jn(2,-1) == 0.114... */
+ TESTIT2_R (jn, 3, 5.0, 0.36, 0.37); /* jn(3,5) == 0.364... */
+ TESTIT2_R (jn, 3, -5.0, -0.37, -0.36); /* jn(3,-5) == -0.364... */
+
+ TESTIT2_R (jn, -2, 1.0, 0.11, 0.12); /* jn(-2,1) == 0.114... */
+ TESTIT2_R (jn, -2, -1.0, 0.11, 0.12); /* jn(-2,-1) == 0.114... */
+ TESTIT2_R (jn, -3, 5.0, -0.37, -0.36); /* jn(-3,5) == -0.364... */
+ TESTIT2_R (jn, -3, -5.0, 0.36, 0.37); /* jn(-3,-5) == 0.364... */
+
+ TESTIT2_R (jn, 4, 3.5, 0.20, 0.21); /* jn(4,3.5) == 0.204... */
+ TESTIT2_R (jn, 4, -3.5, 0.20, 0.21); /* jn(4,-3.5) == 0.204... */
+ TESTIT2_R (jn, 5, 4.6, 0.20, 0.21); /* jn(5,4.6) == 0.207... */
+ TESTIT2_R (jn, 5, -4.6, -0.21, -0.20); /* jn(5,-4.6) == -0.207... */
+
+ TESTIT2_R (jn, -4, 3.5, 0.20, 0.21); /* jn(-4,3.5) == 0.204... */
+ TESTIT2_R (jn, -4, -3.5, 0.20, 0.21); /* jn(-4,-3.5) == 0.204... */
+ TESTIT2_R (jn, -5, 4.6, -0.21, -0.20); /* jn(-5,4.6) == -0.207... */
+ TESTIT2_R (jn, -5, -4.6, 0.20, 0.21); /* jn(-5,-4.6) == 0.207... */
+
+ TESTIT_R (y0, 5.0, -0.31, -0.30); /* y0(5) == -0.308... */
+ TESTIT_R (y0, 0.1, -1.54, -1.53); /* y0(0.1) == -1.534... */
+
+ TESTIT_R (y1, 5.0, 0.14, 0.15); /* y1(5) == 0.147... */
+ TESTIT_R (y1, 0.1, -6.46, -6.45); /* y1(0.1) == -6.458... */
+
+ TESTIT2_R (yn, -1, 3.0, -0.33, -0.32); /* yn(-1,3) == -0.324... */
+ TESTIT2_R (yn, -1, 0.25, 2.70, 2.71); /* yn(-1,0.25) == 2.704... */
+
+ TESTIT2_R (yn, 2, 4.0, 0.21, 0.22); /* yn(2,4) == 0.215... */
+ TESTIT2_R (yn, 2, 0.9, -1.95, -1.94); /* yn(2,0.9) == -1.945... */
+ TESTIT2_R (yn, -2, 4.0, 0.21, 0.22); /* yn(-2,4) == 0.215... */
+ TESTIT2_R (yn, -2, 0.9, -1.95, -1.94); /* yn(-2,0.9) == -1.945... */
+
+ TESTIT2_R (yn, 3, 6.0, 0.32, 0.33); /* yn(3,6) == 0.328... */
+ TESTIT2_R (yn, 3, 0.89, -8.03, -8.02); /* yn(3,0.89) == -8.020... */
+ TESTIT2_R (yn, -3, 8.0, -0.03, -0.02); /* yn(-3,8) == -0.026... */
+ TESTIT2_R (yn, -3, 0.99, 5.98, 5.99); /* yn(-3,0.99) == 5.982... */
+
+#ifdef __OPTIMIZE__
+ /* These tests rely on propagating the variable q, which happens
+ only when optimization is turned on. This macro also tests
+ remainder/drem. */
+ TESTIT2_REMQUO (0.0, 1.0, q, 0.0, 0); /* remquo(0,1,&q)==0, q==0 */
+ TESTIT2_REMQUO (1.0, 1.0, q, 0.0, 1); /* remquo(1,1,&q)==0, q==1 */
+ TESTIT2_REMQUO (2.0, 1.0, q, 0.0, 2); /* remquo(2,1,&q)==0, q==2 */
+ TESTIT2_REMQUO (-0.0, 1.0, q, -0.0, 0); /* remquo(-0,1,&q)==-0, q==0 */
+ TESTIT2_REMQUO (-1.0, 1.0, q, -0.0, -1); /* remquo(-1,1,&q)==-0, q==-1 */
+ TESTIT2_REMQUO (-2.0, 1.0, q, -0.0, -2); /* remquo(-2,1,&q)==-0, q==-2 */
+
+ TESTIT2_REMQUO (0.0, -1.0, q, 0.0, 0); /* remquo(0,-1,&q)==0, q==0 */
+ TESTIT2_REMQUO (1.0, -1.0, q, 0.0, -1); /* remquo(1,-1,&q)==0, q==-1 */
+ TESTIT2_REMQUO (2.0, -1.0, q, 0.0, -2); /* remquo(2,-1,&q)==0, q==-2 */
+ TESTIT2_REMQUO (-0.0, -1.0, q, -0.0, 0); /* remquo(-0,-1,&q)==-0, q==0 */
+ TESTIT2_REMQUO (-1.0, -1.0, q, -0.0, 1); /* remquo(-1,-1,&q)==-0, q==1 */
+ TESTIT2_REMQUO (-2.0, -1.0, q, -0.0, 2); /* remquo(-2,-1,&q)==-0, q==2 */
+
+ TESTIT2_REMQUO (1.0, 2.0, q, 1.0, 0); /* remquo(1,2,&q)==1, q==0 */
+ TESTIT2_REMQUO (3.0, 2.0, q, -1.0, 2); /* remquo(3,2,&q)==-1, q==2 */
+ TESTIT2_REMQUO (5.0, 2.0, q, 1.0, 2); /* remquo(5,2,&q)==1, q==2 */
+ TESTIT2_REMQUO (-1.0, 2.0, q, -1.0, 0); /* remquo(-1,2,&q)==-1, q==0 */
+ TESTIT2_REMQUO (-3.0, 2.0, q, 1.0, -2); /* remquo(-3,2,&q)==1, q==-2 */
+ TESTIT2_REMQUO (-5.0, 2.0, q, -1.0, -2); /* remquo(-5,2,&q)==-1, q==-2 */
+
+ TESTIT2_REMQUO (1.0, -2.0, q, 1.0, 0); /* remquo(1,-2,&q)==1, q==0 */
+ TESTIT2_REMQUO (3.0, -2.0, q, -1.0, -2); /* remquo(3,-2,&q)==-1, q==-2 */
+ TESTIT2_REMQUO (5.0, -2.0, q, 1.0, -2); /* remquo(5,-2,&q)==1, q==-2 */
+ TESTIT2_REMQUO (-1.0, -2.0, q, -1.0, 0); /* remquo(-1,-2,&q)==-1, q==0 */
+ TESTIT2_REMQUO (-3.0, -2.0, q, 1.0, 2); /* remquo(-3,-2,&q)==1, q==2 */
+ TESTIT2_REMQUO (-5.0, -2.0, q, -1.0, 2); /* remquo(-5,-2,&q)==-1, q==2 */
+
+ /* Test that the maximum possible value can be generated into the
+ int quotient, and check for wrap around (modulo) when that value
+ is exceeded. We can only check for this when the mantissa has
+ enough bits to hold an INT_MAX value with complete precision. */
+
+#define MAXIT(FUNC,X,R) do { \
+ q = 12345; \
+ if (__builtin_##FUNC((X), 1, &q) != 0 || q != (R)) \
+ link_error (__LINE__); \
+} while (0)
+
+ if (sizeof(int)*__CHAR_BIT__ <= __FLT_MANT_DIG__)
+ {
+ MAXIT(remquof, __INT_MAX__-1.0F, __INT_MAX__-1);
+ MAXIT(remquof, __INT_MAX__+0.0F, __INT_MAX__);
+ MAXIT(remquof, __INT_MAX__+1.0F, 0);
+ MAXIT(remquof, __INT_MAX__+2.0F, 1);
+
+ MAXIT(remquof, -(__INT_MAX__-1.0F), -(__INT_MAX__-1));
+ MAXIT(remquof, -(__INT_MAX__+0.0F), -__INT_MAX__);
+ MAXIT(remquof, -(__INT_MAX__+1.0F), 0);
+ MAXIT(remquof, -(__INT_MAX__+2.0F), -1);
+ }
+
+ if (sizeof(int)*__CHAR_BIT__ <= __DBL_MANT_DIG__)
+ {
+ MAXIT(remquo, __INT_MAX__-1.0, __INT_MAX__-1);
+ MAXIT(remquo, __INT_MAX__+0.0, __INT_MAX__);
+ MAXIT(remquo, __INT_MAX__+1.0, 0);
+ MAXIT(remquo, __INT_MAX__+2.0, 1);
+
+ MAXIT(remquo, -(__INT_MAX__-1.0), -(__INT_MAX__-1));
+ MAXIT(remquo, -(__INT_MAX__+0.0), -__INT_MAX__);
+ MAXIT(remquo, -(__INT_MAX__+1.0), 0);
+ MAXIT(remquo, -(__INT_MAX__+2.0), -1);
+ }
+
+ if (sizeof(int)*__CHAR_BIT__ <= __LDBL_MANT_DIG__)
+ {
+ MAXIT(remquo, __INT_MAX__-1.0L, __INT_MAX__-1);
+ MAXIT(remquo, __INT_MAX__+0.0L, __INT_MAX__);
+ MAXIT(remquo, __INT_MAX__+1.0L, 0);
+ MAXIT(remquo, __INT_MAX__+2.0L, 1);
+
+ MAXIT(remquol, -(__INT_MAX__-1.0L), -(__INT_MAX__-1));
+ MAXIT(remquol, -(__INT_MAX__+0.0L), -__INT_MAX__);
+ MAXIT(remquol, -(__INT_MAX__+1.0L), 0);
+ MAXIT(remquol, -(__INT_MAX__+2.0L), -1);
+ }
+
+ /* These tests rely on propagating the variable sg which contains
+ signgam. This happens only when optimization is turned on. */
+ TESTIT_LGAMMA_REENT_R (lgamma, -2.5, -0.06, -0.05, -1); /* lgamma_r(-2.5) == -0.056... */
+ TESTIT_LGAMMA_REENT_R (lgamma, -1.5, 0.86, 0.87, 1); /* lgamma_r(-1.5) == 0.860... */
+ TESTIT_LGAMMA_REENT_R (lgamma, -0.5, 1.26, 1.27, -1); /* lgamma_r(-0.5) == 1.265... */
+ TESTIT_LGAMMA_REENT_R (lgamma, 0.5, 0.57, 0.58, 1); /* lgamma_r(0.5) == 0.572... */
+ TESTIT_LGAMMA_REENT (lgamma, 1.0, 0.0, 1); /* lgamma_r(1) == 0 */
+ TESTIT_LGAMMA_REENT_R (lgamma, 1.5, -0.13, -0.12, 1); /* lgamma_r(1.5) == -0.120... */
+ TESTIT_LGAMMA_REENT (lgamma, 2.0, 0.0, 1); /* lgamma_r(2) == 0 */
+ TESTIT_LGAMMA_REENT_R (lgamma, 2.5, 0.28, 0.29, 1); /* lgamma_r(2.5) == 0.284... */
+
+ TESTIT_LGAMMA_REENT_R (gamma, -2.5, -0.06, -0.05, -1); /* gamma_r(-2.5) == -0.056... */
+ TESTIT_LGAMMA_REENT_R (gamma, -1.5, 0.86, 0.87, 1); /* gamma_r(-1.5) == 0.860... */
+ TESTIT_LGAMMA_REENT_R (gamma, -0.5, 1.26, 1.27, -1); /* gamma_r(-0.5) == 1.265... */
+ TESTIT_LGAMMA_REENT_R (gamma, 0.5, 0.57, 0.58, 1); /* gamma_r(0.5) == 0.572... */
+ TESTIT_LGAMMA_REENT (gamma, 1.0, 0.0, 1); /* gamma_r(1) == 0 */
+ TESTIT_LGAMMA_REENT_R (gamma, 1.5, -0.13, -0.12, 1); /* gamma_r(1.5) == -0.120... */
+ TESTIT_LGAMMA_REENT (gamma, 2.0, 0.0, 1); /* gamma_r(2) == 0 */
+ TESTIT_LGAMMA_REENT_R (gamma, 2.5, 0.28, 0.29, 1); /* gamma_r(2.5) == 0.284... */
+#endif
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/builtin-math-5.c b/gcc/testsuite/gcc.dg/torture/builtin-math-5.c
new file mode 100644
index 000000000..259164107
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/builtin-math-5.c
@@ -0,0 +1,123 @@
+/* Copyright (C) 2009 Free Software Foundation.
+
+ Test things that should block GCC from optimizing compile-time
+ constants passed to a builtin complex transcendental functions.
+
+ Origin: Kaveh R. Ghazi, January 28, 2009. */
+
+/* { dg-do compile } */
+/* { dg-options "-fdump-tree-original" } */
+
+extern void foof (_Complex float);
+extern void foo (_Complex double);
+extern void fool (_Complex long double);
+
+#define TESTIT(FUNC, ARG) do { \
+ foof (__builtin_##FUNC##f (ARG##F)); \
+ foo (__builtin_##FUNC (ARG)); \
+ fool (__builtin_##FUNC##l (ARG##L)); \
+} while (0)
+
+#define TESTIT2(FUNC, ARG0, ARG1) do { \
+ foof (__builtin_##FUNC##f (ARG0##F, ARG1##F)); \
+ foo (__builtin_##FUNC (ARG0, ARG1)); \
+ fool (__builtin_##FUNC##l (ARG0##L, ARG1##L)); \
+} while (0)
+
+void bar()
+{
+ /* An argument of NaN is not evaluated at compile-time. */
+#ifndef __SPU__
+ foof (__builtin_csqrtf (__builtin_nanf("")));
+#endif
+ foo (__builtin_csqrt (__builtin_nan("")));
+ fool (__builtin_csqrtl (__builtin_nanl("")));
+
+ /* An argument of Inf/-Inf is not evaluated at compile-time. */
+#ifndef __SPU__
+ foof (__builtin_csqrtf (__builtin_inff()));
+#endif
+ foo (__builtin_csqrt (__builtin_inf()));
+ fool (__builtin_csqrtl (__builtin_infl()));
+#ifndef __SPU__
+ foof (__builtin_csqrtf (-__builtin_inff()));
+#endif
+ foo (__builtin_csqrt (-__builtin_inf()));
+ fool (__builtin_csqrtl (-__builtin_infl()));
+
+ /* Check for overflow/underflow. */
+ TESTIT (cexp, 1e20);
+ TESTIT (cexp, -1e20);
+
+ /* An argument of NaN is not evaluated at compile-time. */
+#ifndef __SPU__
+ foof (__builtin_cpowf (__builtin_nanf(""), 2.5F));
+#endif
+ foo (__builtin_cpow (__builtin_nan(""), 2.5));
+ fool (__builtin_cpowl (__builtin_nanl(""), 2.5L));
+#ifndef __SPU__
+ foof (__builtin_cpowf (2.5F, __builtin_nanf("")));
+#endif
+ foo (__builtin_cpow (2.5, __builtin_nan("")));
+ fool (__builtin_cpowl (2.5L, __builtin_nanl("")));
+
+ /* An argument of Inf/-Inf is not evaluated at compile-time. */
+#ifndef __SPU__
+ foof (__builtin_cpowf (__builtin_inff(), 2.5F));
+#endif
+ foo (__builtin_cpow (__builtin_inf(), 2.5));
+ fool (__builtin_cpowl (__builtin_infl(), 2.5L));
+#ifndef __SPU__
+ foof (__builtin_cpowf (-__builtin_inff(), 2.5F));
+#endif
+ foo (__builtin_cpow (-__builtin_inf(), 2.5));
+ fool (__builtin_cpowl (-__builtin_infl(), 2.5L));
+#ifndef __SPU__
+ foof (__builtin_cpowf (2.5F, __builtin_inff()));
+#endif
+ foo (__builtin_cpow (2.5, __builtin_inf()));
+ fool (__builtin_cpowl (2.5L, __builtin_infl()));
+#ifndef __SPU__
+ foof (__builtin_cpowf (2.5F, -__builtin_inff()));
+#endif
+ foo (__builtin_cpow (2.5, -__builtin_inf()));
+ fool (__builtin_cpowl (2.5L, -__builtin_infl()));
+
+ /* Check for Inv/NaN return values. */
+ TESTIT2 (cpow, -0.0, -4.5); /* Returns Inf */
+ TESTIT2 (cpow, 0.0, -4.5); /* Returns Inf */
+
+ /* Check for overflow/underflow. */
+ foof (__builtin_cpowf (__FLT_MAX__, 3.5F));
+ foof (__builtin_cpowf (__FLT_MAX__ * 1.FI, 3.5F));
+ foo (__builtin_cpow (__DBL_MAX__, 3.5));
+ foo (__builtin_cpow (__DBL_MAX__ * 1.I, 3.5));
+ fool (__builtin_cpowl (__LDBL_MAX__, 3.5L));
+ fool (__builtin_cpowl (__LDBL_MAX__ * 1.LI, 3.5L));
+ TESTIT2 (cpow, 2.0, 0x1p50);
+ TESTIT2 (cpow, 2.0, 0x1p28);
+ TESTIT2 (cpow, 2.0, 0x1p24);
+ foof (__builtin_cpowf (__FLT_MAX__, -3.5F));
+ foof (__builtin_cpowf (__FLT_MAX__ * 1.FI, -3.5F));
+ foo (__builtin_cpow (__DBL_MAX__, -3.5));
+ foo (__builtin_cpow (__DBL_MAX__ * 1.I, -3.5));
+ fool (__builtin_cpowl (__LDBL_MAX__, -3.5L));
+ fool (__builtin_cpowl (__LDBL_MAX__ * 1.LI, -3.5L));
+ TESTIT2 (cpow, 2.0, -0x1p50);
+ TESTIT2 (cpow, 2.0, -0x1p28);
+ TESTIT2 (cpow, 2.0, -0x1p24);
+
+}
+
+/* { dg-final { scan-tree-dump-times "csqrtf" 3 "original" { target { ! { spu*-*-* } } } } } */
+/* { dg-final { scan-tree-dump-times "csqrtf" 0 "original" { target { spu*-*-* } } } } */
+/* { dg-final { scan-tree-dump-times "csqrt " 3 "original" } } */
+/* { dg-final { scan-tree-dump-times "csqrtl" 3 "original" } } */
+/* { dg-final { scan-tree-dump-times "cexpf" 2 "original" } } */
+/* { dg-final { scan-tree-dump-times "cexp " 2 "original" } } */
+/* { dg-final { scan-tree-dump-times "cexpl" 2 "original" } } */
+/* { dg-final { scan-tree-dump-times "cpowf" 18 "original" { target { ! { spu*-*-* } } } } } */
+/* { dg-final { scan-tree-dump-times "cpowf" 12 "original" { target { spu*-*-* } } } } */
+/* { dg-final { scan-tree-dump-times "cpow " 18 "original" } } */
+/* { dg-final { scan-tree-dump-times "cpowl" 18 "original" } } */
+/* { dg-final { cleanup-tree-dump "original" } } */
diff --git a/gcc/testsuite/gcc.dg/torture/builtin-math-6.c b/gcc/testsuite/gcc.dg/torture/builtin-math-6.c
new file mode 100644
index 000000000..462c7d3ee
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/builtin-math-6.c
@@ -0,0 +1,302 @@
+/* Copyright (C) 2009 Free Software Foundation.
+
+ Verify that folding of built-in complex math functions with
+ constant arguments is correctly performed by the compiler.
+
+ Origin: Kaveh R. Ghazi, January 28, 2009. */
+
+/* { dg-do link } */
+
+/* All references to link_error should go away at compile-time. The
+ first number is the line number and the second is the value number
+ among several tests. These appear in the tree dump file and aid in
+ debugging. */
+extern void link_error(int, int);
+
+#define CONJ(X) __builtin_conjf(X)
+
+/* Return TRUE if the signs of floating point values X and Y are not
+ equal. This is important when comparing signed zeros. */
+#define CKSGN_F(X,Y) \
+ (__builtin_copysignf(1,(X)) != __builtin_copysignf(1,(Y)))
+#define CKSGN(X,Y) \
+ (__builtin_copysign(1,(X)) != __builtin_copysign(1,(Y)))
+#define CKSGN_L(X,Y) \
+ (__builtin_copysignl(1,(X)) != __builtin_copysignl(1,(Y)))
+
+/* Return TRUE if signs of the real parts, and the signs of the
+ imaginary parts, of X and Y are not equal. */
+#define COMPLEX_CKSGN_F(X,Y) \
+ (CKSGN_F(__real__ (X), __real__ (Y)) || CKSGN_F (__imag__ (X), __imag__ (Y)))
+#define COMPLEX_CKSGN(X,Y) \
+ (CKSGN(__real__ (X), __real__ (Y)) || CKSGN (__imag__ (X), __imag__ (Y)))
+#define COMPLEX_CKSGN_L(X,Y) \
+ (CKSGN_L(__real__ (X), __real__ (Y)) || CKSGN_L (__imag__ (X), __imag__ (Y)))
+
+/* For complex numbers, test that FUNC(ARG) == (RES). */
+#define TESTIT_COMPLEX(VAL_NUM, FUNC, ARG, RES) do { \
+ if (__builtin_##FUNC##f(ARG) != (RES) \
+ || COMPLEX_CKSGN_F(__builtin_##FUNC##f(ARG), (RES))) \
+ link_error(__LINE__, VAL_NUM); \
+ if (__builtin_##FUNC(ARG) != (RES) \
+ || COMPLEX_CKSGN(__builtin_##FUNC(ARG), (RES))) \
+ link_error(__LINE__, VAL_NUM); \
+ if (__builtin_##FUNC##l(ARG) != (RES) \
+ || COMPLEX_CKSGN_L(__builtin_##FUNC##l(ARG), (RES))) \
+ link_error(__LINE__, VAL_NUM); \
+ } while (0)
+
+/* For complex numbers, call the TESTIT_COMPLEX macro for all
+ combinations of neg and conj. */
+#define TESTIT_COMPLEX_ALLNEG(FUNC, ARG, RES1, RES2, RES3, RES4) do { \
+ TESTIT_COMPLEX(1, FUNC, (_Complex float)(ARG), RES1); \
+ TESTIT_COMPLEX(2, FUNC, -CONJ(ARG), RES2); \
+ TESTIT_COMPLEX(3, FUNC, CONJ(ARG), RES3); \
+ TESTIT_COMPLEX(4, FUNC, -(_Complex float)(ARG), RES4); \
+} while (0)
+
+/* For complex numbers, call the TESTIT_COMPLEX_R macro for all
+ combinations of neg and conj. */
+#define TESTIT_COMPLEX_R_ALLNEG(FUNC, ARG, RES1, RES2, RES3, RES4) do { \
+ TESTIT_COMPLEX_R(1, FUNC, (_Complex float)(ARG), RES1); \
+ TESTIT_COMPLEX_R(2, FUNC, -CONJ(ARG), RES2); \
+ TESTIT_COMPLEX_R(3, FUNC, CONJ(ARG), RES3); \
+ TESTIT_COMPLEX_R(4, FUNC, -(_Complex float)(ARG), RES4); \
+} while (0)
+
+/* For complex numbers, test that FUNC(ARG0, ARG1) == (RES). */
+#define TESTIT_COMPLEX2(VAL_NUM, FUNC, ARG0, ARG1, RES) do { \
+ if (__builtin_##FUNC##f(ARG0, ARG1) != (RES) \
+ || COMPLEX_CKSGN_F(__builtin_##FUNC##f(ARG0, ARG1), (RES))) \
+ link_error(__LINE__, VAL_NUM); \
+ if (__builtin_##FUNC(ARG0, ARG1) != (RES) \
+ || COMPLEX_CKSGN(__builtin_##FUNC(ARG0, ARG1), (RES))) \
+ link_error(__LINE__, VAL_NUM); \
+ if (__builtin_##FUNC##l(ARG0, ARG1) != (RES) \
+ || COMPLEX_CKSGN_L(__builtin_##FUNC##l(ARG0, ARG1), (RES))) \
+ link_error(__LINE__, VAL_NUM); \
+ } while (0)
+
+/* For complex numbers, call the TESTIT_COMPLEX2 macro for all
+ combinations of neg and conj. */
+#define TESTIT_COMPLEX2_ALLNEG(FUNC, ARG0, ARG1, RES1, RES2, RES3, RES4, RES5,\
+ RES6, RES7, RES8, RES9, RES10, RES11, RES12, RES13, RES14, RES15, RES16) do{ \
+ TESTIT_COMPLEX2(1, FUNC, (_Complex float)(ARG0),(_Complex float)(ARG1), RES1);\
+ TESTIT_COMPLEX2(2, FUNC, (_Complex float)(ARG0),CONJ(ARG1), RES2); \
+ TESTIT_COMPLEX2(3, FUNC, (_Complex float)(ARG0),-(_Complex float)(ARG1), RES3); \
+ TESTIT_COMPLEX2(4, FUNC, (_Complex float)(ARG0),-CONJ(ARG1), RES4); \
+ TESTIT_COMPLEX2(5, FUNC, -(_Complex float)(ARG0),(_Complex float)(ARG1), RES5); \
+ TESTIT_COMPLEX2(6, FUNC, -(_Complex float)(ARG0),CONJ(ARG1), RES6); \
+ TESTIT_COMPLEX2(7, FUNC, -(_Complex float)(ARG0),-(_Complex float)(ARG1), RES7); \
+ TESTIT_COMPLEX2(8, FUNC, -(_Complex float)(ARG0),-CONJ(ARG1), RES8); \
+ TESTIT_COMPLEX2(9, FUNC, CONJ(ARG0),(_Complex float)(ARG1), RES9); \
+ TESTIT_COMPLEX2(10, FUNC, CONJ(ARG0),CONJ(ARG1), RES10); \
+ TESTIT_COMPLEX2(11, FUNC, CONJ(ARG0),-(_Complex float)(ARG1), RES11); \
+ TESTIT_COMPLEX2(12, FUNC, CONJ(ARG0),-CONJ(ARG1), RES12); \
+ TESTIT_COMPLEX2(13, FUNC, -CONJ(ARG0),(_Complex float)(ARG1), RES13); \
+ TESTIT_COMPLEX2(14, FUNC, -CONJ(ARG0),CONJ(ARG1), RES14); \
+ TESTIT_COMPLEX2(15, FUNC, -CONJ(ARG0),-(_Complex float)(ARG1), RES15); \
+ TESTIT_COMPLEX2(16, FUNC, -CONJ(ARG0),-CONJ(ARG1), RES16); \
+} while (0)
+
+/* Return TRUE if X differs from EXPECTED by more than 1%. If
+ EXPECTED is zero, then any difference may return TRUE. We don't
+ worry about signed zeros. */
+#define DIFF1PCT_F(X,EXPECTED) \
+ (__builtin_fabsf((X)-(EXPECTED)) * 100 > __builtin_fabsf(EXPECTED))
+#define DIFF1PCT(X,EXPECTED) \
+ (__builtin_fabs((X)-(EXPECTED)) * 100 > __builtin_fabs(EXPECTED))
+#define DIFF1PCT_L(X,EXPECTED) \
+ (__builtin_fabsl((X)-(EXPECTED)) * 100 > __builtin_fabsl(EXPECTED))
+
+/* Return TRUE if complex value X differs from EXPECTED by more than
+ 1% in either the real or imaginary parts. */
+#define COMPLEX_DIFF1PCT_F(X,EXPECTED) \
+ (DIFF1PCT_F(__real__ (X), __real__ (EXPECTED)) \
+ || DIFF1PCT_F(__imag__ (X), __imag__ (EXPECTED)))
+#define COMPLEX_DIFF1PCT(X,EXPECTED) \
+ (DIFF1PCT(__real__ (X), __real__ (EXPECTED)) \
+ || DIFF1PCT(__imag__ (X), __imag__ (EXPECTED)))
+#define COMPLEX_DIFF1PCT_L(X,EXPECTED) \
+ (DIFF1PCT_L(__real__ (X), __real__ (EXPECTED)) \
+ || DIFF1PCT_L(__imag__ (X), __imag__ (EXPECTED)))
+
+/* Range test, for complex numbers check that FUNC(ARG) is within 1%
+ of RES. This is NOT a test for accuracy to the last-bit, we're
+ merely checking that we get relatively sane results. I.e. the GCC
+ builtin is hooked up to the correct MPC function call. We first
+ check the magnitude and then the sign. */
+#define TESTIT_COMPLEX_R(VAL_NUM, FUNC, ARG, RES) do { \
+ if (COMPLEX_DIFF1PCT_F (__builtin_##FUNC##f(ARG), (RES)) \
+ || COMPLEX_CKSGN_F(__builtin_##FUNC##f(ARG), (RES))) \
+ link_error(__LINE__, VAL_NUM); \
+ if (COMPLEX_DIFF1PCT (__builtin_##FUNC(ARG), (RES)) \
+ || COMPLEX_CKSGN(__builtin_##FUNC(ARG), (RES))) \
+ link_error(__LINE__, VAL_NUM); \
+ if (COMPLEX_DIFF1PCT (__builtin_##FUNC(ARG), (RES)) \
+ || COMPLEX_CKSGN(__builtin_##FUNC(ARG), (RES))) \
+ link_error(__LINE__, VAL_NUM); \
+ } while (0)
+
+/* Range test, for complex numbers check that FUNC(ARG0, ARG1) is
+ within 1% of RES. This is NOT a test for accuracy to the last-bit,
+ we're merely checking that we get relatively sane results.
+ I.e. the GCC builtin is hooked up to the correct MPC function call.
+ We first check the magnitude and then the sign. */
+#define TESTIT_COMPLEX_R2(VAL_NUM, FUNC, ARG0, ARG1, RES) do { \
+ if (COMPLEX_DIFF1PCT_F (__builtin_##FUNC##f(ARG0, ARG1), (RES)) \
+ || COMPLEX_CKSGN_F (__builtin_##FUNC##f(ARG0, ARG1), (RES))) \
+ link_error(__LINE__, VAL_NUM); \
+ if (COMPLEX_DIFF1PCT (__builtin_##FUNC(ARG0, ARG1), (RES)) \
+ || COMPLEX_CKSGN (__builtin_##FUNC(ARG0, ARG1), (RES))) \
+ link_error(__LINE__, VAL_NUM); \
+ if (COMPLEX_DIFF1PCT_L (__builtin_##FUNC##l(ARG0, ARG1), (RES)) \
+ || COMPLEX_CKSGN_L (__builtin_##FUNC##l(ARG0, ARG1), (RES))) \
+ link_error(__LINE__, VAL_NUM); \
+ } while (0)
+
+/* For complex numbers, call the TESTIT_COMPLEX_R2 macro for all
+ combinations of neg and conj. */
+#define TESTIT_COMPLEX_R2_ALLNEG(FUNC, ARG0, ARG1, RES1, RES2, RES3, RES4, RES5,\
+ RES6, RES7, RES8, RES9, RES10, RES11, RES12, RES13, RES14, RES15, RES16) do{ \
+ TESTIT_COMPLEX_R2(1, FUNC, (_Complex float)(ARG0),(_Complex float)(ARG1), RES1);\
+ TESTIT_COMPLEX_R2(2, FUNC, (_Complex float)(ARG0),CONJ(ARG1), RES2); \
+ TESTIT_COMPLEX_R2(3, FUNC, (_Complex float)(ARG0),-(_Complex float)(ARG1), RES3); \
+ TESTIT_COMPLEX_R2(4, FUNC, (_Complex float)(ARG0),-CONJ(ARG1), RES4); \
+ TESTIT_COMPLEX_R2(5, FUNC, -(_Complex float)(ARG0),(_Complex float)(ARG1), RES5); \
+ TESTIT_COMPLEX_R2(6, FUNC, -(_Complex float)(ARG0),CONJ(ARG1), RES6); \
+ TESTIT_COMPLEX_R2(7, FUNC, -(_Complex float)(ARG0),-(_Complex float)(ARG1), RES7); \
+ TESTIT_COMPLEX_R2(8, FUNC, -(_Complex float)(ARG0),-CONJ(ARG1), RES8); \
+ TESTIT_COMPLEX_R2(9, FUNC, CONJ(ARG0),(_Complex float)(ARG1), RES9); \
+ TESTIT_COMPLEX_R2(10, FUNC, CONJ(ARG0),CONJ(ARG1), RES10); \
+ TESTIT_COMPLEX_R2(11, FUNC, CONJ(ARG0),-(_Complex float)(ARG1), RES11); \
+ TESTIT_COMPLEX_R2(12, FUNC, CONJ(ARG0),-CONJ(ARG1), RES12); \
+ TESTIT_COMPLEX_R2(13, FUNC, -CONJ(ARG0),(_Complex float)(ARG1), RES13); \
+ TESTIT_COMPLEX_R2(14, FUNC, -CONJ(ARG0),CONJ(ARG1), RES14); \
+ TESTIT_COMPLEX_R2(15, FUNC, -CONJ(ARG0),-(_Complex float)(ARG1), RES15); \
+ TESTIT_COMPLEX_R2(16, FUNC, -CONJ(ARG0),-CONJ(ARG1), RES16); \
+} while (0)
+
+int main (void)
+{
+ TESTIT_COMPLEX (1, cacos, 1, CONJ(0));
+ TESTIT_COMPLEX_R (1, cacos, -1, CONJ(3.141593F));
+ TESTIT_COMPLEX (1, cacos, CONJ(1), 0);
+ TESTIT_COMPLEX_R (1, cacos, CONJ(-1), 3.141593F);
+ TESTIT_COMPLEX_R_ALLNEG (cacos, 3.45678F + 2.34567FI,
+ 0.60971F - 2.11780FI, 2.531875F - 2.117800FI,
+ 0.60971F + 2.11780FI, 2.531875F + 2.117800FI);
+
+ TESTIT_COMPLEX_ALLNEG (casin, 0,
+ 0, -CONJ(0), CONJ(0), CONJ(-0.F));
+ TESTIT_COMPLEX_R_ALLNEG (casin, 3.45678F + 2.34567FI,
+ 0.96107F + 2.11780FI, -0.96107F + 2.11780FI,
+ 0.96107F - 2.11780FI, -0.96107F - 2.11780FI);
+
+ TESTIT_COMPLEX_ALLNEG (catan, 0,
+ 0, -CONJ(0), CONJ(0), CONJ(-0.F));
+ TESTIT_COMPLEX_R_ALLNEG (catan, 3.45678F + 2.34567FI,
+ 1.37188F + 0.12997FI, -1.37188F + 0.12997FI,
+ 1.37188F - 0.12997FI, -1.37188F - 0.12997FI);
+
+ TESTIT_COMPLEX (1, cacosh, 1, 0);
+ TESTIT_COMPLEX_R (1, cacosh, -1, 3.141593FI);
+ TESTIT_COMPLEX (1, cacosh, CONJ(1), CONJ(0));
+ TESTIT_COMPLEX_R (1, cacosh, CONJ(-1), CONJ(3.141593FI));
+ TESTIT_COMPLEX_R_ALLNEG (cacosh, 3.45678F + 2.34567FI,
+ 2.11780F + 0.60971FI, 2.11780F + 2.531875FI,
+ 2.11780F - 0.60971FI, 2.11780F - 2.531875FI);
+
+ TESTIT_COMPLEX_ALLNEG (casinh, 0,
+ 0, -CONJ(0), CONJ(0), CONJ(-0.F));
+ TESTIT_COMPLEX_R_ALLNEG (casinh, 3.45678F + 2.34567FI,
+ 2.12836F + 0.58310FI, -2.12836F + 0.58310FI,
+ 2.12836F - 0.58310FI, -2.12836F - 0.58310FI);
+
+ TESTIT_COMPLEX_ALLNEG (catanh, 0,
+ 0, -CONJ(0), CONJ(0), CONJ(-0.F));
+ TESTIT_COMPLEX_R_ALLNEG (catanh, 3.45678F + 2.34567FI,
+ 0.19693F + 1.43190FI, -0.19693F + 1.43190FI,
+ 0.19693F - 1.43190FI, -0.19693F - 1.43190FI);
+
+ TESTIT_COMPLEX_ALLNEG (csin, 0,
+ 0, -0.F, CONJ(0), CONJ(-0.F));
+ TESTIT_COMPLEX_R_ALLNEG (csin, 3.45678F + 2.34567FI,
+ -1.633059F - 4.917448FI, 1.633059F - 4.917448FI,
+ -1.633059F + 4.917448FI, 1.633059F + 4.917448FI);
+
+ TESTIT_COMPLEX_ALLNEG (ccos, 0,
+ CONJ(1), 1, 1, CONJ(1));
+ TESTIT_COMPLEX_R_ALLNEG (ccos, 3.45678F + 2.34567FI,
+ -5.008512F + 1.603367FI, -5.008512F - 1.603367FI,
+ -5.008512F - 1.603367FI, -5.008512F + 1.603367FI);
+
+ TESTIT_COMPLEX_ALLNEG (ctan, 0,
+ 0, -0.F, CONJ(0), CONJ(-0.F));
+ TESTIT_COMPLEX_R_ALLNEG (ctan, 3.45678F + 2.34567FI,
+ 0.010657F + 0.985230FI, -0.010657F + 0.985230FI,
+ 0.010657F - 0.985230FI, -0.010657F - 0.985230FI);
+
+ TESTIT_COMPLEX_ALLNEG (csinh, 0,
+ 0, -0.F, CONJ(0), CONJ(-0.F));
+ TESTIT_COMPLEX_R_ALLNEG (csinh, 3.45678F + 2.34567FI,
+ -11.083178F + 11.341487FI, 11.083178F +11.341487FI,
+ -11.083178F - 11.341487FI, 11.083178F -11.341487FI);
+
+ TESTIT_COMPLEX_ALLNEG (ccosh, 0,
+ 1, CONJ(1), CONJ(1), 1);
+ TESTIT_COMPLEX_R_ALLNEG (ccosh, 3.45678F + 2.34567FI,
+ -11.105238F + 11.318958FI,-11.105238F -11.318958FI,
+ -11.105238F - 11.318958FI,-11.105238F +11.318958FI);
+
+ TESTIT_COMPLEX_ALLNEG (ctanh, 0,
+ 0, -0.F, CONJ(0), CONJ(-0.F));
+ TESTIT_COMPLEX_R_ALLNEG (ctanh, 3.45678F + 2.34567FI,
+ 1.000040F - 0.001988FI, -1.000040F - 0.001988FI,
+ 1.000040F + 0.001988FI, -1.000040F + 0.001988FI);
+
+ TESTIT_COMPLEX (1, clog, 1, 0);
+ TESTIT_COMPLEX_R (1, clog, -1, 3.141593FI);
+ TESTIT_COMPLEX (1, clog, CONJ(1), CONJ(0));
+ TESTIT_COMPLEX_R (1, clog, CONJ(-1), CONJ(3.141593FI));
+ TESTIT_COMPLEX_R_ALLNEG (clog, 3.45678F + 2.34567FI,
+ 1.429713F + 0.596199FI, 1.429713F + 2.545394FI,
+ 1.429713F - 0.596199FI, 1.429713F - 2.545394FI);
+
+ TESTIT_COMPLEX_ALLNEG (csqrt, 0,
+ 0, 0, CONJ(0), CONJ(0));
+ TESTIT_COMPLEX_R_ALLNEG (csqrt, 3.45678F + 2.34567FI,
+ 1.953750F + 0.600299FI, 0.600299F + 1.953750FI,
+ 1.953750F - 0.600299FI, 0.600299F - 1.953750FI);
+
+ TESTIT_COMPLEX2_ALLNEG (cpow, 1, 0,
+ 1, 1, CONJ(1), CONJ(1), CONJ(1), CONJ(1), 1, 1,
+ CONJ(1), CONJ(1), 1, 1, 1, 1, CONJ(1), CONJ(1));
+ TESTIT_COMPLEX2_ALLNEG (cpow, 1.FI, 0,
+ 1, 1, CONJ(1), CONJ(1), CONJ(1), CONJ(1), 1, 1,
+ CONJ(1), CONJ(1), 1, 1, 1, 1, CONJ(1), CONJ(1));
+ TESTIT_COMPLEX_R2_ALLNEG (cpow, 2, 3,
+ 8, 8, CONJ(1/8.F), CONJ(1/8.F), CONJ(-8), CONJ(-8), -1/8.F, -1/8.F,
+ CONJ(8), CONJ(8), 1/8.F, 1/8.F, -8, -8, CONJ(-1/8.F), CONJ(-1/8.F));
+ TESTIT_COMPLEX_R2_ALLNEG (cpow, 3, 4,
+ 81, 81, CONJ(1/81.F), CONJ(1/81.F), CONJ(81), CONJ(81), 1/81.F, 1/81.F,
+ CONJ(81), CONJ(81), 1/81.F, 1/81.F, 81, 81, CONJ(1/81.F), CONJ(1/81.F));
+ TESTIT_COMPLEX_R2_ALLNEG (cpow, 3, 5,
+ 243, 243, CONJ(1/243.F), CONJ(1/243.F), CONJ(-243), CONJ(-243), -1/243.F, -1/243.F,
+ CONJ(243), CONJ(243), 1/243.F, 1/243.F, -243, -243, CONJ(-1/243.F), CONJ(-1/243.F));
+ TESTIT_COMPLEX_R2_ALLNEG (cpow, 4, 2,
+ 16, 16, CONJ(1/16.F), CONJ(1/16.F), CONJ(16), CONJ(16), 1/16.F, 1/16.F,
+ CONJ(16), CONJ(16), 1/16.F, 1/16.F, 16, 16, CONJ(1/16.F), CONJ(1/16.F));
+ TESTIT_COMPLEX_R2_ALLNEG (cpow, 1.5, 3,
+ 3.375F, 3.375F, CONJ(1/3.375F), CONJ(1/3.375F), CONJ(-3.375F), CONJ(-3.375F), -1/3.375F, -1/3.375F,
+ CONJ(3.375F), CONJ(3.375F), 1/3.375F, 1/3.375F, -3.375F, -3.375F, CONJ(-1/3.375F), CONJ(-1/3.375F));
+
+ TESTIT_COMPLEX2 (1, cpow, 16, 0.25F, 2);
+
+ TESTIT_COMPLEX_R2 (1, cpow, 3.45678F + 2.34567FI, 1.23456 + 4.56789FI, 0.212485F + 0.319304FI);
+ TESTIT_COMPLEX_R2 (1, cpow, 3.45678F - 2.34567FI, 1.23456 + 4.56789FI, 78.576402F + -41.756208FI);
+ TESTIT_COMPLEX_R2 (1, cpow, -1.23456F + 2.34567FI, 2.34567 - 1.23456FI, -110.629847F + -57.021655FI);
+ TESTIT_COMPLEX_R2 (1, cpow, -1.23456F - 2.34567FI, 2.34567 - 1.23456FI, 0.752336F + 0.199095FI);
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/builtin-math-7.c b/gcc/testsuite/gcc.dg/torture/builtin-math-7.c
new file mode 100644
index 000000000..5bc432924
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/builtin-math-7.c
@@ -0,0 +1,99 @@
+/* Copyright (C) 2009 Free Software Foundation.
+
+ Verify that folding of complex mul and div work correctly.
+
+ Origin: Kaveh R. Ghazi, August 13, 2009. */
+
+/* { dg-do run } */
+/* { dg-add-options ieee } */
+
+extern void link_error(int);
+
+/* Evaluate this expression at compile-time. */
+#define COMPILETIME_TESTIT(TYPE,X,OP,Y,RES) do { \
+ if ((_Complex TYPE)(X) OP (_Complex TYPE)(Y) != (_Complex TYPE)(RES)) \
+ link_error(__LINE__); \
+} while (0)
+
+/* Use this error function for cases which only evaluate at
+ compile-time when optimizing. */
+#ifdef __OPTIMIZE__
+# define ERROR_FUNC(X) link_error(X)
+#else
+# define ERROR_FUNC(X) __builtin_abort()
+#endif
+
+/* Evaluate this expression at compile-time using static initializers. */
+#define STATICINIT_TESTIT(TYPE,X,OP,Y,RES) do { \
+ static const _Complex TYPE foo = (_Complex TYPE)(X) OP (_Complex TYPE)(Y); \
+ if (foo != (_Complex TYPE)(RES)) \
+ ERROR_FUNC (__LINE__); \
+} while (0)
+
+/* Evaluate this expression at runtime. */
+#define RUNTIME_TESTIT(TYPE,X,OP,Y,RES) do { \
+ volatile _Complex TYPE foo; \
+ foo = (_Complex TYPE)(X); \
+ foo OP##= (_Complex TYPE)(Y); \
+ if (foo != (_Complex TYPE)(RES)) \
+ __builtin_abort(); \
+} while (0)
+
+/* Evaluate this expression at compile-time and runtime. */
+#define TESTIT(TYPE,X,OP,Y,RES) do { \
+ STATICINIT_TESTIT(TYPE,X,OP,Y,RES); \
+ COMPILETIME_TESTIT(TYPE,X,OP,Y,RES); \
+ RUNTIME_TESTIT(TYPE,X,OP,Y,RES); \
+} while (0)
+
+/* Either the real or imaginary parts should be infinity. */
+#define TEST_ONE_PART_INF(VAL) do { \
+ static const _Complex double foo = (VAL); \
+ if (! __builtin_isinf(__real foo) && ! __builtin_isinf(__imag foo)) \
+ ERROR_FUNC (__LINE__); \
+ if (! __builtin_isinf(__real (VAL)) && ! __builtin_isinf(__imag (VAL))) \
+ __builtin_abort(); \
+} while (0)
+
+int main()
+{
+ /* Test some regular finite values. */
+ TESTIT (double, 3.+4.i, *, 2, 6+8i);
+ TESTIT (double, 3.+4.i, /, 2, 1.5+2i);
+ TESTIT (int, 3+4i, *, 2, 6+8i);
+ TESTIT (int, 3+4i, /, 2, 1+2i);
+
+ TESTIT (double, 3.+4.i, *, 2+5i, -14+23i);
+ TESTIT (double, 3.+4.i, /, 5i, .8-.6i);
+ TESTIT (int, 3+4i, *, 2+5i, -14+23i);
+ TESTIT (int, 30+40i, /, 5i, 8-6i);
+ TESTIT (int, 14+6i, /, 7+3i, 2);
+ TESTIT (int, 8+24i, /, 4+12i, 2);
+
+ /* Test that we don't overflow. */
+ TESTIT (double,
+ (__DBL_MAX__ * 0.5 + __DBL_MAX__ * 0.5i),
+ /,
+ (__DBL_MAX__ * 0.25 + __DBL_MAX__ * 0.25i),
+ 2);
+
+ /* Test for accuracy. */
+ COMPILETIME_TESTIT (double,
+ (1 + __DBL_EPSILON__ + 1i),
+ *,
+ (1 - __DBL_EPSILON__ + 1i),
+ -4.93038065763132378382330353301741393545754021943139377981e-32+2i);
+
+ /* This becomes (NaN + iInf). */
+#define VAL1 ((_Complex double)__builtin_inf() * 1i)
+
+ /* Test some C99 Annex G special cases. */
+ TEST_ONE_PART_INF ((VAL1) * (VAL1));
+ TEST_ONE_PART_INF ((_Complex double)1 / (_Complex double)0);
+ TEST_ONE_PART_INF ((VAL1) / (_Complex double)1);
+
+ RUNTIME_TESTIT (double, 1, /, VAL1, 0);
+ STATICINIT_TESTIT (double, 1, /, VAL1, 0);
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/builtin-math-8.c b/gcc/testsuite/gcc.dg/torture/builtin-math-8.c
new file mode 100644
index 000000000..1a1a843e7
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/builtin-math-8.c
@@ -0,0 +1,34 @@
+/* { dg-do link } */
+
+extern void link_error (void);
+
+int main()
+{
+ if (!__builtin_constant_p(1.0))
+ link_error ();
+ if (!__builtin_constant_p(__builtin_fma (1.0, 1.0, 1.0)))
+ link_error ();
+
+ if (__builtin_constant_p(__builtin_fmaf (__FLT_MAX__, __FLT_MAX__, 0.0F)))
+ link_error ();
+ if (__builtin_constant_p(__builtin_fmaf (__FLT_MAX__, 1.0F, __FLT_MAX__)))
+ link_error ();
+ if (__builtin_constant_p(__builtin_fmaf (__FLT_MIN__, __FLT_MIN__, 0.0F)))
+ link_error ();
+
+ if (__builtin_constant_p(__builtin_fma (__DBL_MAX__, __DBL_MAX__, 0.0)))
+ link_error ();
+ if (__builtin_constant_p(__builtin_fma (__DBL_MAX__, 1.0, __DBL_MAX__)))
+ link_error ();
+ if (__builtin_constant_p(__builtin_fma (__DBL_MIN__, __DBL_MIN__, 0.0)))
+ link_error ();
+
+ if (__builtin_constant_p(__builtin_fmal (__LDBL_MAX__, __LDBL_MAX__, 0.0L)))
+ link_error ();
+ if (__builtin_constant_p(__builtin_fmal (__LDBL_MAX__, 1.0L, __LDBL_MAX__)))
+ link_error ();
+ if (__builtin_constant_p(__builtin_fmal (__LDBL_MIN__, __LDBL_MIN__, 0.0L)))
+ link_error ();
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/builtin-minmax-1.c b/gcc/testsuite/gcc.dg/torture/builtin-minmax-1.c
new file mode 100644
index 000000000..13831ad3a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/builtin-minmax-1.c
@@ -0,0 +1,128 @@
+/* Copyright (C) 2006 Free Software Foundation.
+
+ Verify that built-in math function folding of fmin/fmax is
+ correctly performed by the compiler.
+
+ Origin: Kaveh R. Ghazi, November 13, 2006. */
+
+/* { dg-do link } */
+/* { dg-options "-fno-math-errno" } */
+
+/* All references to link_error should go away at compile-time. */
+extern void link_error(int);
+
+#define DECLARE(FUNC) \
+ extern float FUNC##f (float); \
+ extern double FUNC (double); \
+ extern long double FUNC##l (long double)
+#define DECLARE2(FUNC) \
+ extern float FUNC##f (float, float); \
+ extern double FUNC (double, double); \
+ extern long double FUNC##l (long double, long double)
+
+DECLARE2(fmin);
+DECLARE2(fmax);
+DECLARE(fabs);
+extern int pure(int) __attribute__ ((__pure__));
+
+/* Test that FUNC(x,x) == x. We cast to (long) so "!=" folds. */
+#define TEST_EQ(FUNC) do { \
+ if ((long)FUNC##f(xf,xf) != (long)xf) \
+ link_error(__LINE__); \
+ if ((long)FUNC(x,x) != (long)x) \
+ link_error(__LINE__); \
+ if ((long)FUNC##l(xl,xl) != (long)xl) \
+ link_error(__LINE__); \
+ } while (0)
+
+/* Test that FUNC(purefn,purefn) == purefn. We cast to (long) so "!=" folds. */
+#define TEST_EQ_PURE(FUNC) do { \
+ if ((long)FUNC##f(pure(i),pure(i)) != (long)FUNC##f(pure(i),pure(i))) \
+ link_error(__LINE__); \
+ if ((long)FUNC(pure(i),pure(i)) != (long)FUNC(pure(i),pure(i))) \
+ link_error(__LINE__); \
+ if ((long)FUNC##l(pure(i),pure(i)) != (long)FUNC##l(pure(i),pure(i))) \
+ link_error(__LINE__); \
+ } while (0)
+
+/* Test that FIXFUNC(FUNC(int1,int2)) == (TYPE)FUNC(int1,int2),
+ i.e. FIXFUNC should be folded away and replaced with a cast. */
+#define TEST_FIXFUNC(FUNC,FIXFUNC,TYPE) do { \
+ if (FIXFUNC##f(FUNC##f(i,j)) != (TYPE)FUNC##f(i,j)) \
+ link_error(__LINE__); \
+ if (FIXFUNC(FUNC(i,j)) != (TYPE)FUNC(i,j)) \
+ link_error(__LINE__); \
+ if (FIXFUNC##l(FUNC##l(i,j)) != (TYPE)FUNC##l(i,j)) \
+ link_error(__LINE__); \
+ } while (0)
+
+/* Test that FUNC(int1,int2) has an integer return type. */
+#define TEST_INT(FUNC) do { \
+ TEST_FIXFUNC(FUNC,__builtin_lround,long); \
+ TEST_FIXFUNC(FUNC,__builtin_llround,long long); \
+ TEST_FIXFUNC(FUNC,__builtin_lrint,long); \
+ TEST_FIXFUNC(FUNC,__builtin_llrint,long long); \
+ TEST_FIXFUNC(FUNC,__builtin_lceil,long); \
+ TEST_FIXFUNC(FUNC,__builtin_llceil,long long); \
+ TEST_FIXFUNC(FUNC,__builtin_lfloor,long); \
+ TEST_FIXFUNC(FUNC,__builtin_llfloor,long long); \
+ } while (0)
+
+/* Test that (long)fabs(FUNC(fabs(x),fabs(y))) ==
+ (long)FUNC(fabs(x),fabs(y)). We cast to (long) so "!=" folds. */
+#define TEST_NONNEG(FUNC) do { \
+ if ((long)fabsf(FUNC##f(fabsf(xf),fabsf(yf))) != (long)FUNC##f(fabsf(xf),fabsf(yf))) \
+ link_error(__LINE__); \
+ if ((long)fabs(FUNC(fabs(x),fabs(y))) != (long)FUNC(fabs(x),fabs(y))) \
+ link_error(__LINE__); \
+ if ((long)fabsl(FUNC##l(fabsl(xl),fabsl(yl))) != (long)FUNC##l(fabsl(xl),fabsl(yl))) \
+ link_error(__LINE__); \
+ } while (0)
+
+/* Test that FUNC(NaN,x) == x. We cast to (long) so "!=" folds. Set
+ parameter SIGNAL to `s' for testing signaling NaN. */
+#define TEST_NAN(FUNC,SIGNAL) do { \
+ if ((long)FUNC##f(__builtin_nan##SIGNAL##f(""),xf) != (long)xf) \
+ link_error(__LINE__); \
+ if ((long)FUNC##f(xf,__builtin_nan##SIGNAL##f("")) != (long)xf) \
+ link_error(__LINE__); \
+ if ((long)FUNC(__builtin_nan##SIGNAL(""),x) != (long)x) \
+ link_error(__LINE__); \
+ if ((long)FUNC(x,__builtin_nan##SIGNAL("")) != (long)x) \
+ link_error(__LINE__); \
+ if ((long)FUNC##l(__builtin_nan##SIGNAL##l(""),xl) != (long)xl) \
+ link_error(__LINE__); \
+ if ((long)FUNC##l(xl,__builtin_nan##SIGNAL##l("")) != (long)xl) \
+ link_error(__LINE__); \
+ } while (0)
+
+void __attribute__ ((__noinline__))
+ foo (float xf, double x, long double xl,
+ float yf, double y, long double yl,
+ int i, int j)
+{
+ TEST_EQ(fmin);
+ TEST_EQ(fmax);
+
+#ifdef __OPTIMIZE__
+ TEST_EQ_PURE(fmin);
+ TEST_EQ_PURE(fmax);
+#endif
+
+ TEST_INT(fmin);
+ TEST_INT(fmax);
+
+ TEST_NONNEG(fmin);
+ TEST_NONNEG(fmax);
+
+ TEST_NAN(fmin,);
+ TEST_NAN(fmax,);
+ TEST_NAN(fmin,s);
+ TEST_NAN(fmax,s);
+}
+
+int main()
+{
+ foo (1,1,1,1,1,1,1,1);
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/builtin-modf-1.c b/gcc/testsuite/gcc.dg/torture/builtin-modf-1.c
new file mode 100644
index 000000000..05e16ac2c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/builtin-modf-1.c
@@ -0,0 +1,195 @@
+/* Copyright (C) 2007 Free Software Foundation.
+
+ Verify that built-in folding of modf is correctly performed by the
+ compiler.
+
+ Origin: Kaveh R. Ghazi, February 23, 2007. */
+
+/* { dg-do link } */
+/* { dg-options "-fno-finite-math-only" { target sh*-*-* } } */
+/* { dg-options "-funsafe-math-optimizations -fsigned-zeros -fno-associative-math" { target powerpc-*-darwin* powerpc*-*-linux* } } */
+
+extern void link_error(int);
+
+/* Return TRUE if the sign of X != sign of Y. This is important when
+ comparing signed zeros. */
+#define CKSGN_F(X,Y) \
+ (__builtin_copysignf(1.0F,(X)) != __builtin_copysignf(1.0F,(Y)))
+#define CKSGN(X,Y) \
+ (__builtin_copysign(1.0,(X)) != __builtin_copysign(1.0,(Y)))
+#define CKSGN_L(X,Y) \
+ (__builtin_copysignl(1.0L,(X)) != __builtin_copysignl(1.0L,(Y)))
+
+/* We use these macros if we can only check these when optimizing. In
+ some cases we rely on other optimizations to propagate the value
+ and fold away certain constructs. Likewise for the sign testing.
+ TRUE means an error occurred. */
+#ifdef __OPTIMIZE__
+#define CKRES(X) (X)
+#define CKIPTR(X,Y) X != Y
+#define CKSGN_IPTR_F(X,Y) CKSGN_F(X,Y)
+#define CKSGN_IPTR(X,Y) CKSGN(X,Y)
+#define CKSGN_IPTR_L(X,Y) CKSGN_L(X,Y)
+#else
+#define CKRES(X) 0
+#define CKIPTR(X,Y) 0
+#define CKSGN_IPTR_F(X,Y) 0
+#define CKSGN_IPTR(X,Y) 0
+#define CKSGN_IPTR_L(X,Y) 0
+#endif
+
+/* Test that modf(ARG1,&iptr) == FRACRES && iptr == INTRES. Check the
+ sign in case we get -0.0. */
+#define TESTIT_MODF(ARG,INTRES,FRACRES) do { \
+ float iptrf = 0.5; double iptr = 0.5; long double iptrl = 0.5; \
+ if (__builtin_modff(ARG##f,&iptrf) != FRACRES##f \
+ || CKIPTR(iptrf,INTRES##f) \
+ || CKSGN_F(__builtin_modff(ARG##f,&iptrf),FRACRES##f) \
+ || CKSGN_IPTR_F(iptrf,INTRES##f)) \
+ link_error(__LINE__); \
+ if (__builtin_modf(ARG,&iptr) != FRACRES \
+ || CKIPTR(iptr,INTRES) \
+ || CKSGN(__builtin_modf(ARG,&iptr),FRACRES) \
+ || CKSGN_IPTR(iptr,INTRES)) \
+ link_error(__LINE__); \
+ if (__builtin_modfl(ARG##l,&iptrl) != FRACRES##l \
+ || CKIPTR(iptrl,INTRES##l) \
+ || CKSGN_L(__builtin_modfl(ARG##l,&iptrl),FRACRES##l) \
+ || CKSGN_IPTR_L(iptrl,INTRES##l)) \
+ link_error(__LINE__); \
+ } while (0)
+
+/* Test that modf(NEG FUNCARG(ARGARG, &iptr)) == FRACRES &&
+ FUNCRES(iptr) is true. Check the sign of both as well. This is
+ for checking an argument of Inf. */
+#ifndef __SPU__
+#define TESTIT_MODF2(NEG,FUNCARG,ARGARG,FUNCRES,FRACRES) do { \
+ float iptrf = 0.5; double iptr = 0.5; long double iptrl = 0.5; \
+ if (__builtin_modff(NEG __builtin_##FUNCARG##f(ARGARG),&iptrf) != FRACRES##f \
+ || CKSGN_F(__builtin_modff(NEG __builtin_##FUNCARG##f(ARGARG),&iptrf), FRACRES##f) \
+ || CKIPTR(!__builtin_##FUNCRES##f(iptrf),0) \
+ || CKSGN_IPTR_F(iptrf,FRACRES##f)) \
+ link_error(__LINE__); \
+ if (__builtin_modf(NEG __builtin_##FUNCARG(ARGARG),&iptr) != FRACRES \
+ || CKSGN(__builtin_modf(NEG __builtin_##FUNCARG(ARGARG),&iptr), FRACRES) \
+ || CKIPTR(!__builtin_##FUNCRES(iptr),0) \
+ || CKSGN_IPTR(iptr,FRACRES)) \
+ link_error(__LINE__); \
+ if (__builtin_modfl(NEG __builtin_##FUNCARG##l(ARGARG),&iptrl) != FRACRES##l \
+ || CKSGN_L(__builtin_modfl(NEG __builtin_##FUNCARG##l(ARGARG),&iptrl), FRACRES##l) \
+ || CKIPTR(!__builtin_##FUNCRES##l(iptrl),0) \
+ || CKSGN_IPTR_L(iptrl,FRACRES##l)) \
+ link_error(__LINE__); \
+ } while (0)
+#else
+#define TESTIT_MODF2(NEG,FUNCARG,ARGARG,FUNCRES,FRACRES) do { \
+ /* SPU single-precision floating point format does not support Inf or Nan. */ \
+ double iptr = 0.5; long double iptrl = 0.5; \
+ if (__builtin_modf(NEG __builtin_##FUNCARG(ARGARG),&iptr) != FRACRES \
+ || CKSGN(__builtin_modf(NEG __builtin_##FUNCARG(ARGARG),&iptr), FRACRES) \
+ || CKIPTR(!__builtin_##FUNCRES(iptr),0) \
+ || CKSGN_IPTR(iptr,FRACRES)) \
+ link_error(__LINE__); \
+ if (__builtin_modfl(NEG __builtin_##FUNCARG##l(ARGARG),&iptrl) != FRACRES##l \
+ || CKSGN_L(__builtin_modfl(NEG __builtin_##FUNCARG##l(ARGARG),&iptrl), FRACRES##l) \
+ || CKIPTR(!__builtin_##FUNCRES##l(iptrl),0) \
+ || CKSGN_IPTR_L(iptrl,FRACRES##l)) \
+ link_error(__LINE__); \
+ } while (0)
+#endif
+
+/* Test that FUNCRES(modf(NEG FUNCARG(ARGARG, &iptr))) is true &&
+ FUNCRES(iptr) is true. Check the sign of both as well. This is
+ for checking an argument of NaN. */
+#ifndef __SPU__
+#define TESTIT_MODF3(NEG,FUNCARG,ARGARG,FUNCRES) do { \
+ float iptrf = 0.5; double iptr = 0.5; long double iptrl = 0.5; \
+ if (CKRES(!__builtin_##FUNCRES##f(__builtin_modff(NEG __builtin_##FUNCARG##f(ARGARG),&iptrf))) \
+ || CKSGN_F(__builtin_modff(NEG __builtin_##FUNCARG##f(ARGARG),&iptrf), NEG 1) \
+ || CKIPTR(!__builtin_##FUNCRES##f(iptrf),0) \
+ || CKSGN_IPTR_F(iptrf,NEG 1)) \
+ link_error(__LINE__); \
+ if (CKRES(!__builtin_##FUNCRES(__builtin_modf(NEG __builtin_##FUNCARG(ARGARG),&iptr))) \
+ || CKSGN(__builtin_modf(NEG __builtin_##FUNCARG(ARGARG),&iptr), NEG 1) \
+ || CKIPTR(!__builtin_##FUNCRES(iptr),0) \
+ || CKSGN_IPTR(iptr,NEG 1)) \
+ link_error(__LINE__); \
+ if (CKRES(!__builtin_##FUNCRES##l(__builtin_modfl(NEG __builtin_##FUNCARG##l(ARGARG),&iptrl))) \
+ || CKSGN_L(__builtin_modfl(NEG __builtin_##FUNCARG##l(ARGARG),&iptrl), NEG 1) \
+ || CKIPTR(!__builtin_##FUNCRES##l(iptrl),0) \
+ || CKSGN_IPTR_L(iptrl,NEG 1)) \
+ link_error(__LINE__); \
+ } while (0)
+#else
+#define TESTIT_MODF3(NEG,FUNCARG,ARGARG,FUNCRES) do { \
+ /* SPU single-precision floating point format does not support Inf or Nan. */ \
+ double iptr = 0.5; long double iptrl = 0.5; \
+ if (CKRES(!__builtin_##FUNCRES(__builtin_modf(NEG __builtin_##FUNCARG(ARGARG),&iptr))) \
+ || CKSGN(__builtin_modf(NEG __builtin_##FUNCARG(ARGARG),&iptr), NEG 1) \
+ || CKIPTR(!__builtin_##FUNCRES(iptr),0) \
+ || CKSGN_IPTR(iptr,NEG 1)) \
+ link_error(__LINE__); \
+ if (CKRES(!__builtin_##FUNCRES##l(__builtin_modfl(NEG __builtin_##FUNCARG##l(ARGARG),&iptrl))) \
+ || CKSGN_L(__builtin_modfl(NEG __builtin_##FUNCARG##l(ARGARG),&iptrl), NEG 1) \
+ || CKIPTR(!__builtin_##FUNCRES##l(iptrl),0) \
+ || CKSGN_IPTR_L(iptrl,NEG 1)) \
+ link_error(__LINE__); \
+ } while (0)
+#endif
+
+void __attribute__ ((__noinline__))
+foo(void)
+{
+ /* Test that modf(ARG1,&iptr) -> ARG3 && iptr == ARG2. */
+ TESTIT_MODF (0x1p10F+0.5, 0x1p10, 0.5);
+ TESTIT_MODF (0x1p10F+0x1p-10, 0x1p10, 0x1p-10);
+ TESTIT_MODF (12345678L/17.0, 726216.0, -726216L+12345678L/17.0);
+ TESTIT_MODF (555.555, 555.0, -555+555.555);
+ TESTIT_MODF (5000/11.0, 454.0, -454+5000/11.0);
+ TESTIT_MODF (1000/7.0, 142.0, -142+1000/7.0);
+ TESTIT_MODF (123/7.0, 17.0, -17+123/7.0);
+ TESTIT_MODF (117/7.0, 16.0, -16+117/7.0);
+ TESTIT_MODF (5.5, 5.0, 0.5);
+ TESTIT_MODF (1.5, 1.0, 0.5);
+ TESTIT_MODF (4/3.0, 1.0, -1+4/3.0);
+ TESTIT_MODF (1.0, 1.0, 0.0);
+ TESTIT_MODF (0.5, 0.0, 0.5);
+ TESTIT_MODF (4/9.0, 0.0, 4/9.0);
+ TESTIT_MODF (1/3.0, 0.0, 1/3.0);
+ TESTIT_MODF (1/9.0, 0.0, 1/9.0);
+ TESTIT_MODF (0.0, 0.0, 0.0);
+
+ TESTIT_MODF (-0.0, -0.0, -0.0);
+ TESTIT_MODF (-1/9.0, -0.0, -1/9.0);
+ TESTIT_MODF (-1/3.0, -0.0, -1/3.0);
+ TESTIT_MODF (-4/9.0, -0.0, -4/9.0);
+ TESTIT_MODF (-0.5, -0.0, -0.5);
+ TESTIT_MODF (-1.0, -1.0, -0.0);
+ TESTIT_MODF (-4/3.0, -1.0, 1-4/3.0);
+ TESTIT_MODF (-1.5, -1.0, -0.5);
+ TESTIT_MODF (-5.5, -5.0, -0.5);
+ TESTIT_MODF (-117/7.0, -16.0, 16-117/7.0);
+ TESTIT_MODF (-123/7.0, -17.0, 17-123/7.0);
+ TESTIT_MODF (-1000/7.0, -142.0, 142-1000/7.0);
+ TESTIT_MODF (-5000/11.0, -454.0, 454-5000/11.0);
+ TESTIT_MODF (-555.555, -555.0, 555-555.555);
+ TESTIT_MODF (-12345678L/17.0, -726216.0, 726216L-12345678L/17.0);
+ TESTIT_MODF (-0x1p10F-0x1p-10, -0x1p10, -0x1p-10);
+ TESTIT_MODF (-0x1p10F-0.5, -0x1p10, -0.5);
+
+
+ /* Test for modf(+-Inf,&i) -> (i=+-0.0, +-Inf). */
+ TESTIT_MODF2 ( ,inf, , isinf, 0.0);
+ TESTIT_MODF2 (- ,inf, , isinf, -0.0);
+
+ /* Test for and modf(+-NaN,&i) -> (i=+-NaN, +-NaN). */
+ TESTIT_MODF3 ( ,nan, "", isnan);
+ TESTIT_MODF3 (- ,nan, "", isnan);
+}
+
+int main()
+{
+ foo();
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/builtin-nonneg-1.c b/gcc/testsuite/gcc.dg/torture/builtin-nonneg-1.c
new file mode 100644
index 000000000..8a3286a59
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/builtin-nonneg-1.c
@@ -0,0 +1,180 @@
+/* Copyright (C) 2004 Free Software Foundation.
+
+ Verify that GCC can determine which built-in functions produce a
+ nonnegative result.
+
+ Written by Kaveh Ghazi, 2004-03-10. */
+
+/* { dg-do link } */
+/* { dg-options "-ffast-math" } */
+
+#define PROTOTYPE_RTYPE(FN,RTYPE) extern RTYPE FN(double); \
+ extern RTYPE FN##f(float); \
+ extern RTYPE FN##l(long double);
+#define PROTOTYPE(FN) extern double FN(double); extern float FN##f(float); \
+ extern long double FN##l(long double);
+#define PROTOTYPE2(FN) extern double FN(double, double); \
+ extern float FN##f(float, float); \
+ extern long double FN##l(long double, long double);
+#define CPROTOTYPE1(FN) extern double FN(_Complex double); \
+ extern float FN##f(_Complex float); \
+ extern long double FN##l(_Complex long double);
+#define CPROTOTYPE1(FN) extern double FN(_Complex double); \
+ extern float FN##f(_Complex float); \
+ extern long double FN##l(_Complex long double);
+#define IPROTOTYPE(FN) extern int FN(int); extern int FN##l(long); \
+ extern int FN##ll(long long);
+#define PROTOTYPE2TYPE2(FN,A2TYPE) extern double FN(double, A2TYPE); \
+ extern float FN##f(float, A2TYPE); \
+ extern long double FN##l(long double, A2TYPE);
+#define PROTOTYPE2_A2FPTR(FN) extern double FN(double, double *); \
+ extern float FN##f(float, float *); \
+ extern long double FN##l(long double, long double *);
+
+extern int signbit (double);
+extern int signbitf (float);
+extern int signbitl (long double);
+
+void test(double d1, double d2, float f1, float f2,
+ long double ld1, long double ld2)
+{
+ /* These are always nonnegative. */
+
+#define TEST1(FN) \
+ extern void link_failure_##FN (void); PROTOTYPE(FN) \
+ if (signbit(FN(d1)) || signbitf(FN##f(f1)) || signbitl(FN##l(ld1))) \
+ link_failure_##FN()
+
+#define TEST2(FN) \
+ extern void link_failure_##FN (void); PROTOTYPE2(FN) \
+ if (signbit(FN(d1,d2)) || signbitf(FN##f(f1,f2)) || signbitl(FN##l(ld1,ld2))) \
+ link_failure_##FN()
+
+#define CTEST1(FN) \
+ extern void link_failure_##FN (void); CPROTOTYPE1(FN) \
+ if (signbit(FN(d1)) || signbitf(FN##f(f1)) || signbitl(FN##l(ld1))) \
+ link_failure_##FN()
+
+#define ITEST1(FN) \
+ extern void link_failure_##FN (void); IPROTOTYPE(FN) \
+ if (signbit(FN(d1)) || signbitf(FN##l(f1)) || signbitl(FN##ll(ld1))) \
+ link_failure_##FN()
+
+ TEST1 (acos);
+ TEST1 (acosh);
+ CTEST1 (cabs);
+ TEST1 (cosh);
+ TEST1 (erfc);
+ TEST1 (exp);
+ TEST1 (exp10);
+ TEST1 (exp2);
+ TEST1 (fabs);
+ TEST2 (fdim);
+ TEST2 (hypot);
+ TEST1 (pow10);
+ TEST1 (sqrt);
+ ITEST1 (ffs);
+ ITEST1 (__builtin_parity);
+ ITEST1 (__builtin_popcount);
+
+ /* These are nonnegative if the first argument is. */
+#define ARG1TEST1(FN) \
+ extern void link_failure_##FN (void); PROTOTYPE(FN) \
+ if (signbit(FN(fabs(d1))) || signbitf(FN##f(fabsf(f1))) \
+ || signbitl(FN##l(fabsl(ld1)))) \
+ link_failure_##FN()
+
+ /* Same, but allow specifying the return type. */
+#define ARG1TEST1_RTYPE(FN,RTYPE) \
+ extern void link_failure_##FN (void); PROTOTYPE_RTYPE(FN,RTYPE) \
+ if (signbit(FN(fabs(d1))) || signbitf(FN##f(fabsf(f1))) \
+ || signbitl(FN##l(fabsl(ld1)))) \
+ link_failure_##FN()
+
+ /* These are nonnegative if the first argument is. */
+#define ARG1TEST2(FN) \
+ extern void link_failure_##FN (void); PROTOTYPE2(FN) \
+ if (signbit(FN(fabs(d1),d2)) || signbitf(FN##f(fabsf(f1),f2)) \
+ || signbitl(FN##l(fabsl(ld1),ld2))) \
+ link_failure_##FN()
+
+ /* These are nonnegative if the second argument is. */
+#define ARG2TEST2(FN) \
+ extern void link_failure_##FN (void); PROTOTYPE2(FN) \
+ if (signbit(FN(d1,fabs(d2))) || signbitf(FN##f(f1,fabsf(f2))) \
+ || signbitl(FN##l(ld1,fabsl(ld2)))) \
+ link_failure_##FN()
+
+ /* These are nonnegative if the first OR second argument is. */
+#define ARG2TESTor(FN) \
+ extern void link_failure_##FN (void); PROTOTYPE2(FN) \
+ if (signbit(FN(fabs(d1),d2)) || signbitf(FN##f(fabsf(f1),f2)) \
+ || signbitl(FN##l(fabsl(ld1),ld2)) || signbit(FN(d1,fabs(d2))) \
+ || signbitf(FN##f(f1,fabsf(f2))) || signbitl(FN##l(ld1,fabsl(ld2)))) \
+ link_failure_##FN()
+
+ /* These are nonnegative if the first AND second argument is. */
+#define ARG2TESTand(FN) \
+ extern void link_failure_##FN (void); PROTOTYPE2(FN) \
+ if (signbit(FN(fabs(d1),fabs(d2))) || signbitf(FN##f(fabsf(f1),fabsf(f2))) \
+ || signbitl(FN##l(fabsl(ld1),fabsl(ld2)))) \
+ link_failure_##FN()
+
+ /* These are nonnegative if the first argument is, 2nd arg is an int. */
+#define ARG1TEST2_A2INT(FN, INTTYPE) \
+ extern void link_failure_##FN (void); PROTOTYPE2TYPE2(FN, INTTYPE) \
+ if (signbit(FN(fabs(d1),d2)) || signbitf(FN##f(fabsf(f1),f2)) \
+ || signbitl(FN##l(fabsl(ld1),ld2))) \
+ link_failure_##FN()
+
+ /* These are nonnegative if the first argument is, specify 2nd arg. */
+#define ARG2TEST1_A2FPTR(FN) \
+ extern void link_failure_##FN (void); PROTOTYPE2_A2FPTR(FN) \
+ if (signbit(FN(fabs(d1),&d2)) || signbitf(FN##f(fabsf(f1),&f2)) \
+ || signbitl(FN##l(fabsl(ld1),&ld2))) \
+ link_failure_##FN()
+
+ ARG1TEST1 (asinh);
+ ARG1TEST1 (atan);
+ ARG1TEST1 (atanh);
+ ARG1TEST1 (cbrt);
+ ARG1TEST1 (ceil);
+ ARG1TEST1 (erf);
+ ARG1TEST1 (expm1);
+ ARG1TEST1 (floor);
+ ARG1TEST2 (fmod);
+ ARG1TEST2_A2INT (ldexp, int);
+ ARG1TEST1_RTYPE (__builtin_llceil, long long);
+ ARG1TEST1_RTYPE (__builtin_llfloor, long long);
+ ARG1TEST1_RTYPE (llrint, long long);
+ ARG1TEST1_RTYPE (llround, long long);
+ ARG1TEST1_RTYPE (__builtin_lceil, long);
+ ARG1TEST1_RTYPE (__builtin_lfloor, long);
+ ARG1TEST1_RTYPE (lrint, long);
+ ARG1TEST1_RTYPE (lround, long);
+ /* The modf* functions aren't ever "const" or "pure" even with
+ -ffast-math so they won't be eliminated and yield a link failure. */
+ /* ARG2TEST1_A2FPTR (modf);*/
+ ARG1TEST1 (nearbyint);
+ ARG1TEST2 (pow);
+ ARG1TEST1 (rint);
+ ARG1TEST1 (round);
+ ARG1TEST2 (scalb);
+ ARG1TEST2_A2INT (scalbln, long);
+ ARG1TEST2_A2INT (scalbn, int);
+ ARG1TEST1_RTYPE (signbit, int);
+ ARG1TEST1 (significand);
+ ARG1TEST1 (sinh);
+ ARG1TEST1 (tanh);
+ ARG1TEST1 (trunc);
+
+ ARG2TESTor (fmax);
+ ARG2TESTand (fmin);
+ ARG2TEST2 (copysign);
+
+}
+
+int main (void)
+{
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/builtin-noret-1.c b/gcc/testsuite/gcc.dg/torture/builtin-noret-1.c
new file mode 100644
index 000000000..d3e97701f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/builtin-noret-1.c
@@ -0,0 +1,79 @@
+/* Test for builtin noreturn attributes. */
+/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
+/* { dg-options "-multiply_defined suppress" { target powerpc-*-darwin* } } */
+/* { dg-do link } */
+/* { dg-require-weak "" } */
+
+extern void abort (void);
+extern void exit (int);
+extern void _exit (int);
+extern void _Exit (int);
+
+extern void tabort (void);
+extern void texit (void);
+extern void t_exit (void);
+extern void t_Exit (void);
+
+extern void link_failure (void);
+
+/* Some libcs have _exit and/or _Exit, and won't allow it to be re-defined,
+ so make it weak. */
+#pragma weak _exit
+#pragma weak _Exit
+
+int
+main (void)
+{
+ volatile int i = 0;
+ if (i)
+ tabort ();
+ if (i)
+ texit ();
+ if (i)
+ t_exit ();
+ if (i)
+ t_Exit ();
+ exit (0);
+}
+
+void
+tabort (void)
+{
+ abort ();
+ link_failure ();
+}
+
+void
+texit (void)
+{
+ exit (1);
+ link_failure ();
+}
+
+void
+t_exit (void)
+{
+ _exit (1);
+ link_failure ();
+}
+
+/* Some non-Unix libcs might not have _exit. */
+void
+_exit (int i)
+{
+ abort ();
+}
+
+void
+t_Exit (void)
+{
+ _Exit (1);
+ link_failure ();
+}
+
+/* Some libcs might not have _Exit. */
+void
+_Exit (int i)
+{
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.dg/torture/builtin-noret-2.c b/gcc/testsuite/gcc.dg/torture/builtin-noret-2.c
new file mode 100644
index 000000000..1103e3d81
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/builtin-noret-2.c
@@ -0,0 +1,89 @@
+/* Test for builtin noreturn attributes when the visible declarations
+ are function-local. Modified from builtin-noret-1.c by Zack Weinberg
+ <zack@codesourcery.com>. */
+/* { dg-options "-multiply_defined suppress" { target powerpc-*-darwin* } } */
+/* { dg-do link } */
+/* { dg-require-weak "" } */
+
+extern void tabort (void);
+extern void texit (void);
+extern void t_exit (void);
+extern void t_Exit (void);
+
+extern void link_failure (void);
+
+int
+main (void)
+{
+ volatile int i = 0;
+ extern void exit (int);
+ if (i)
+ tabort ();
+ if (i)
+ texit ();
+ if (i)
+ t_exit ();
+ if (i)
+ t_Exit ();
+ exit (0);
+}
+
+void
+tabort (void)
+{
+ extern void abort (void);
+ abort ();
+ link_failure ();
+}
+
+void
+texit (void)
+{
+ extern void exit (int);
+ exit (1);
+ link_failure ();
+}
+
+void
+t_exit (void)
+{
+ extern void _exit (int);
+ /* Some non-Unix libcs have _exit, and won't allow it to be re-defined,
+ so make it weak. */
+#pragma weak _exit
+ _exit (1);
+ link_failure ();
+}
+
+/* Some non-Unix libcs might not have _exit. */
+/* Some non-Unix libcs have _exit, and won't allow it to be re-defined,
+ so make it weak. */
+#pragma weak _exit
+void
+_exit (int i)
+{
+ extern void abort (void);
+ abort ();
+}
+
+void
+t_Exit (void)
+{
+ extern void _Exit (int);
+ /* Some libcs have _Exit, and won't allow it to be re-defined,
+ so make it weak. */
+#pragma weak _Exit
+ _Exit (1);
+ link_failure ();
+}
+
+/* Some libcs might not have _Exit. */
+/* Some libcs have _Exit, and won't allow it to be re-defined,
+ so make it weak. */
+#pragma weak _Exit
+void
+_Exit (int i)
+{
+ extern void abort (void);
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.dg/torture/builtin-pow-mpfr-1.c b/gcc/testsuite/gcc.dg/torture/builtin-pow-mpfr-1.c
new file mode 100644
index 000000000..6206b9ee3
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/builtin-pow-mpfr-1.c
@@ -0,0 +1,19 @@
+/* Version 2.2.0 of MPFR had bugs in pow underflow/overflow. This
+ test checks to see if that buggy version was installed. The
+ problem is NOT fixed with the version 2.2.0 "cumulative patch".
+ However it is fixed in version 2.2.1 and presumably later MPFR
+ versions.
+
+ Origin: Kaveh R. Ghazi 12/17/2006. */
+
+/* { dg-do compile } */
+/* { dg-options "-fdump-tree-original" } */
+
+extern double testit()
+{
+ /* This underflows and therefore gcc should not fold it. */
+ return __builtin_pow (0.11, 1.0e38);
+}
+
+/* { dg-final { scan-tree-dump "pow" "original" } } */
+/* { dg-final { cleanup-tree-dump "original" } } */
diff --git a/gcc/testsuite/gcc.dg/torture/builtin-power-1.c b/gcc/testsuite/gcc.dg/torture/builtin-power-1.c
new file mode 100644
index 000000000..d1403c46c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/builtin-power-1.c
@@ -0,0 +1,113 @@
+/* Copyright (C) 2004 Free Software Foundation.
+
+ Verify that built-in folding of various math "power" functions is
+ correctly performed by the compiler.
+
+ Written by Kaveh Ghazi, 2004-03-11. */
+
+/* { dg-do link } */
+/* { dg-options "-ffast-math" } */
+/* { dg-add-options c99_runtime } */
+
+#include "../builtins-config.h"
+
+#ifdef HAVE_C99_RUNTIME
+#define C99CODE(CODE) CODE
+#else
+#define C99CODE(CODE) 0
+#endif
+
+#define PROTOTYPE(FN) extern double FN(double); extern float FN##f(float); \
+ extern long double FN##l(long double);
+#define PROTOTYPE2(FN) extern double FN(double, double); \
+ extern float FN##f(float, float); \
+ extern long double FN##l(long double, long double);
+
+PROTOTYPE(fabs)
+PROTOTYPE(sqrt)
+PROTOTYPE(cbrt)
+PROTOTYPE2(pow)
+
+void test(double d1, double d2, double d3,
+ float f1, float f2, float f3,
+ long double ld1, long double ld2, long double ld3)
+{
+ /* Test N1root(N2root(x)) -> pow(x,1/(N1*N2)). */
+ /* E.g. sqrt(cbrt(x)) -> pow(x,1/6). */
+ /* The `ABS' argument is `fabs' when the transformation only works
+ for nonnegative arguments. Otherwise it's blank. */
+#define ROOT_ROOT(FN1,N1,FN2,N2,ABS) \
+ extern void link_failure_##FN1##_##FN2(void); \
+ if (FN1(FN2(ABS(d1))) != pow(ABS(d1),1.0/(N1*N2)) \
+ || C99CODE (FN1##f(FN2##f(ABS(f1))) != powf(ABS(f1),1.0F/(N1*N2))) \
+ || C99CODE (FN1##l(FN2##l(ABS(ld1))) != powl(ABS(ld1),1.0L/(N1*N2)))) \
+ link_failure_##FN1##_##FN2()
+
+ ROOT_ROOT(sqrt,2,sqrt,2,);
+ ROOT_ROOT(sqrt,2,cbrt,3,);
+ ROOT_ROOT(cbrt,3,sqrt,2,);
+ ROOT_ROOT(cbrt,3,cbrt,3,fabs);
+
+ /* Test pow(Nroot(x),y) -> pow(x,y/N). */
+ /* The `ABS' argument is `fabs' when the transformation only works
+ for nonnegative arguments. Otherwise it's blank. */
+#define POW_ROOT(FN,N,ABS) \
+ extern void link_failure_pow_##FN(void); \
+ if (pow(FN(ABS(d1)), d2) != pow(ABS(d1),d2/N) \
+ || powf(FN##f(ABS(f1)),f2) != powf(ABS(f1),f2/N) \
+ || powl(FN##l(ABS(ld1)),ld2) != powl(ABS(ld1),ld2/N)) \
+ link_failure_pow_##FN()
+
+ POW_ROOT(sqrt,2,);
+ POW_ROOT(cbrt,3,fabs);
+
+ /* Test Nroot(pow(x,y)) -> pow(x,y/N). */
+ /* The `ABS' argument is `fabs' when the transformation only works
+ for nonnegative arguments. Otherwise it's blank. */
+#define ROOT_POW(FN,N,ABS) \
+ extern void link_failure_##FN##_pow(void); \
+ if (FN(pow(ABS(d1), d2)) != pow(ABS(d1),d2/N) \
+ || FN##f(powf(ABS(f1),f2)) != powf(ABS(f1),f2/N) \
+ || FN##l(powl(ABS(ld1),ld2)) != powl(ABS(ld1),ld2/N)) \
+ link_failure_##FN##_pow()
+
+ ROOT_POW(sqrt,2,fabs);
+ ROOT_POW(cbrt,3,fabs);
+
+ /* Test pow(pow(x,y),z) -> pow(x,y*z). */
+#define POW_POW \
+ extern void link_failure_pow_pow(void); \
+ if (pow(pow(fabs(d1), d2), d3) != pow(fabs(d1),d2*d3) \
+ || powf(powf(fabs(f1),f2),f3) != powf(fabs(f1),f2*f3) \
+ || powl(powl(fabs(ld1),ld2),ld3) != powl(fabs(ld1),ld2*ld3)) \
+ link_failure_pow_pow()
+
+ POW_POW;
+
+ /* Test Nroot(x)*Nroot(y) -> Nroot(x*y). */
+#define ROOT_X_ROOT(FN) \
+ extern void link_failure_root_x_root(void); \
+ if (FN(d1)*FN(d2) != FN(d1*d2) \
+ || FN##f(f1)*FN##f(f2) != FN##f(f1*f2) \
+ || FN##l(ld1)*FN##l(ld2) != FN##l(ld1*ld2)) \
+ link_failure_root_x_root()
+
+ ROOT_X_ROOT(sqrt);
+ ROOT_X_ROOT(cbrt);
+
+ /* Test pow(x,y)*pow(x,z) -> pow(x,y+z). */
+#define POW_X_POW \
+ extern void link_failure_pow_x_pow(void); \
+ if (pow(d1,d2)*pow(d1,d3) != pow(d1,d2+d3) \
+ || powf(f1,f2)*powf(f1,f3) != powf(f1,f2+f3) \
+ || powl(ld1,ld2)*powl(ld1,ld3) != powl(ld1,ld2+ld3)) \
+ link_failure_pow_x_pow()
+
+ POW_X_POW;
+
+}
+
+int main (void)
+{
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/builtin-rounding-1.c b/gcc/testsuite/gcc.dg/torture/builtin-rounding-1.c
new file mode 100644
index 000000000..816cffc04
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/builtin-rounding-1.c
@@ -0,0 +1,120 @@
+/* Copyright (C) 2004 Free Software Foundation.
+
+ Check that constant folding of the rounding math functions doesn't
+ break anything and produces the expected results.
+
+ Written by Kaveh Ghazi, 2004-04-29. */
+
+/* { dg-do link } */
+
+extern int link_error (int);
+
+#define TEST(FN, VALUE, RESULT) \
+ if (__builtin_##FN (VALUE) != RESULT) link_error (__LINE__); \
+ if (__builtin_##FN##f (VALUE) != RESULT) link_error (__LINE__); \
+ if (__builtin_##FN##l (VALUE) != RESULT) link_error (__LINE__); \
+
+int
+main (void)
+{
+ TEST(trunc, 0, 0);
+ TEST(floor, 0, 0);
+ TEST(ceil, 0, 0);
+ TEST(round, 0, 0);
+ TEST(lround, 0, 0);
+ TEST(llround, 0, 0);
+ TEST(lfloor, 0, 0);
+ TEST(llfloor, 0, 0);
+ TEST(lceil, 0, 0);
+ TEST(llceil, 0, 0);
+
+ TEST(trunc, 6, 6);
+ TEST(floor, 6, 6);
+ TEST(ceil, 6, 6);
+ TEST(round, 6, 6);
+ TEST(lround, 6, 6);
+ TEST(llround, 6, 6);
+ TEST(lfloor, 6, 6);
+ TEST(llfloor, 6, 6);
+ TEST(lceil, 6, 6);
+ TEST(llceil, 6, 6);
+
+ TEST(trunc, -8, -8);
+ TEST(floor, -8, -8);
+ TEST(ceil, -8, -8);
+ TEST(round, -8, -8);
+ TEST(lround, -8, -8);
+ TEST(llround, -8, -8);
+ TEST(lfloor, -8, -8);
+ TEST(llfloor, -8, -8);
+ TEST(lceil, -8, -8);
+ TEST(llceil, -8, -8);
+
+ TEST(trunc, 3.2, 3);
+ TEST(floor, 3.2, 3);
+ TEST(ceil, 3.2, 4);
+ TEST(round, 3.2, 3);
+ TEST(lround, 3.2, 3);
+ TEST(llround, 3.2, 3);
+ TEST(lfloor, 3.2, 3);
+ TEST(llfloor, 3.2, 3);
+ TEST(lceil, 3.2, 4);
+ TEST(llceil, 3.2, 4);
+
+ TEST(trunc, -2.8, -2);
+ TEST(floor, -2.8, -3);
+ TEST(ceil, -2.8, -2);
+ TEST(round, -2.8, -3);
+ TEST(lround, -2.8, -3);
+ TEST(llround, -2.8, -3);
+ TEST(lfloor, -2.8, -3);
+ TEST(llfloor, -2.8, -3);
+ TEST(lceil, -2.8, -2);
+ TEST(llceil, -2.8, -2);
+
+ TEST(trunc, 0.01, 0);
+ TEST(floor, 0.01, 0);
+ TEST(ceil, 0.01, 1);
+ TEST(round, 0.01, 0);
+ TEST(lround, 0.01, 0);
+ TEST(llround, 0.01, 0);
+ TEST(lfloor, 0.01, 0);
+ TEST(llfloor, 0.01, 0);
+ TEST(lceil, 0.01, 1);
+ TEST(llceil, 0.01, 1);
+
+ TEST(trunc, -0.7, 0);
+ TEST(floor, -0.7, -1);
+ TEST(ceil, -0.7, 0);
+ TEST(round, -0.7, -1);
+ TEST(lround, -0.7, -1);
+ TEST(llround, -0.7, -1);
+ TEST(lfloor, -0.7, -1);
+ TEST(llfloor, -0.7, -1);
+ TEST(lceil, -0.7, 0);
+ TEST(llceil, -0.7, 0);
+
+ TEST(trunc, 2.5, 2);
+ TEST(floor, 2.5, 2);
+ TEST(ceil, 2.5, 3);
+ TEST(round, 2.5, 3);
+ TEST(lround, 2.5, 3);
+ TEST(llround, 2.5, 3);
+ TEST(lfloor, 2.5, 2);
+ TEST(llfloor, 2.5, 2);
+ TEST(lceil, 2.5, 3);
+ TEST(llceil, 2.5, 3);
+
+ TEST(trunc, -1.5, -1);
+ TEST(floor, -1.5, -2);
+ TEST(ceil, -1.5, -1);
+ TEST(round, -1.5, -2);
+ TEST(lround, -1.5, -2);
+ TEST(llround, -1.5, -2);
+ TEST(lfloor, -1.5, -2);
+ TEST(llfloor, -1.5, -2);
+ TEST(lceil, -1.5, -1);
+ TEST(llceil, -1.5, -1);
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/builtin-sin-mpfr-1.c b/gcc/testsuite/gcc.dg/torture/builtin-sin-mpfr-1.c
new file mode 100644
index 000000000..359728708
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/builtin-sin-mpfr-1.c
@@ -0,0 +1,29 @@
+/* Version 2.2.0 of MPFR had bugs in sin rounding. This test checks
+ to see if that buggy version was installed. The problem is fixed
+ in version 2.2.1 and presumably later MPFR versions.
+
+ Origin: Kaveh R. Ghazi 10/23/2006. */
+
+/* { dg-do link } */
+
+extern void link_error (int, double, double);
+
+#define TESTIT(ARG,RES) do { \
+ if (sizeof (double) == 8 && __builtin_sin(ARG) != RES) \
+ link_error(__LINE__, __builtin_sin(ARG), RES); \
+ } while (0);
+
+int main()
+{
+ TESTIT (-0x1.c0016155c4da3p-1, -0x1.88fc58bcf030dp-1);
+
+ TESTIT (0x1.30654d85c2756p-2, 0x1.2beeb9de27a79p-2);
+
+ TESTIT (0x1.fe68ccaa8e201p+2, 0x1.fc3f0c54e97a7p-1);
+
+ /* This case should always pass. */
+ TESTIT (0.0, 0.0);
+
+ return 0;
+}
+
diff --git a/gcc/testsuite/gcc.dg/torture/builtin-symmetric-1.c b/gcc/testsuite/gcc.dg/torture/builtin-symmetric-1.c
new file mode 100644
index 000000000..4834d8e2b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/builtin-symmetric-1.c
@@ -0,0 +1,111 @@
+/* Copyright (C) 2006 Free Software Foundation.
+
+ Verify that built-in math function folding of symmetric even and
+ odd functions is correctly performed by the compiler.
+
+ Origin: Kaveh R. Ghazi, November 09, 2006. */
+
+/* { dg-do link } */
+/* { dg-options "-ffast-math" } */
+
+/* All references to link_error should go away at compile-time. */
+extern void link_error(int);
+
+/* Test that FUNC(-ARG) == FUNC(ARG). */
+#define TESTIT_EVEN(FUNC) do { \
+ if (__builtin_##FUNC##f(-xf) != __builtin_##FUNC##f(xf)) \
+ link_error(__LINE__); \
+ if (__builtin_##FUNC(-x) != __builtin_##FUNC(x)) \
+ link_error(__LINE__); \
+ if (__builtin_##FUNC##l(-xl) != __builtin_##FUNC##l(xl)) \
+ link_error(__LINE__); \
+ } while (0)
+
+/* Test that FUNC(-ARG) == FUNC(ARG), where ARG has a complex type. */
+#define TESTIT_EVEN_C(FUNC) do { \
+ if (__builtin_##FUNC##f(-cxf) != __builtin_##FUNC##f(cxf)) \
+ link_error(__LINE__); \
+ if (__builtin_##FUNC(-cx) != __builtin_##FUNC(cx)) \
+ link_error(__LINE__); \
+ if (__builtin_##FUNC##l(-cxl) != __builtin_##FUNC##l(cxl)) \
+ link_error(__LINE__); \
+ } while (0)
+
+/* Test that FUNC(-VAR) == FUNC(VAR), where VAR has an int type. */
+#define TESTIT_EVEN_I(FUNC,VAR) do { \
+ if (__builtin_##FUNC(-VAR) != __builtin_##FUNC(VAR)) \
+ link_error(__LINE__); \
+ } while (0)
+
+/* Test that -FUNC(ARG) == FUNC(-ARG). */
+#define TESTIT_ODD(FUNC) do { \
+ if (-__builtin_##FUNC##f(-xf) != __builtin_##FUNC##f(xf)) \
+ link_error(__LINE__); \
+ if (-__builtin_##FUNC(-x) != __builtin_##FUNC(x)) \
+ link_error(__LINE__); \
+ if (-__builtin_##FUNC##l(-xl) != __builtin_##FUNC##l(xl)) \
+ link_error(__LINE__); \
+ } while (0)
+
+/* Test that -FUNC(ARG) == FUNC(-ARG), where ARG has a complex type. */
+#define TESTIT_ODD_C(FUNC) do { \
+ if (-__builtin_##FUNC##f(-cxf) != __builtin_##FUNC##f(cxf)) \
+ link_error(__LINE__); \
+ if (-__builtin_##FUNC(-cx) != __builtin_##FUNC(cx)) \
+ link_error(__LINE__); \
+ if (-__builtin_##FUNC##l(-cxl) != __builtin_##FUNC##l(cxl)) \
+ link_error(__LINE__); \
+ } while (0)
+
+void foo (float xf, double x, long double xl,
+ __complex__ float cxf, __complex__ double cx, __complex__ long double cxl,
+ int i, long l, long long ll, __INTMAX_TYPE__ im)
+{
+ TESTIT_EVEN(cos);
+ TESTIT_EVEN(cosh);
+ TESTIT_EVEN(fabs);
+
+ TESTIT_EVEN_C(ccos);
+ TESTIT_EVEN_C(ccosh);
+ TESTIT_EVEN_C(cabs);
+
+ TESTIT_EVEN_I(abs, i);
+ TESTIT_EVEN_I(imaxabs, im);
+ TESTIT_EVEN_I(labs, l);
+ TESTIT_EVEN_I(llabs, ll);
+
+ TESTIT_ODD(asin);
+ TESTIT_ODD(asinh);
+ TESTIT_ODD(atan);
+ TESTIT_ODD(atanh);
+ TESTIT_ODD(cbrt);
+ TESTIT_ODD(erf);
+ TESTIT_ODD(llrint);
+ TESTIT_ODD(llround);
+ TESTIT_ODD(lrint);
+ TESTIT_ODD(lround);
+ TESTIT_ODD(nearbyint);
+ TESTIT_ODD(rint);
+ TESTIT_ODD(round);
+ TESTIT_ODD(sin);
+ TESTIT_ODD(sinh);
+ TESTIT_ODD(tan);
+ TESTIT_ODD(tanh);
+ TESTIT_ODD(trunc);
+
+ TESTIT_ODD_C(casin);
+ TESTIT_ODD_C(casinh);
+ TESTIT_ODD_C(catan);
+ TESTIT_ODD_C(catanh);
+ TESTIT_ODD_C(cproj);
+ TESTIT_ODD_C(csin);
+ TESTIT_ODD_C(csinh);
+ TESTIT_ODD_C(ctan);
+ TESTIT_ODD_C(ctanh);
+}
+
+int main()
+{
+ foo (1,1,1,1,1,1,1,1,1,1);
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/builtin-wctype-1.c b/gcc/testsuite/gcc.dg/torture/builtin-wctype-1.c
new file mode 100644
index 000000000..5b4371e14
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/builtin-wctype-1.c
@@ -0,0 +1,57 @@
+/* Copyright (C) 2004, 2005 Free Software Foundation.
+
+ Verify that built-in wctype function attributes are correctly set
+ by the compiler.
+
+ Written by Kaveh Ghazi, 2004-03-25. */
+
+/* { dg-do link } */
+
+/* Use the target type definitions if we can. */
+#ifndef __WINT_TYPE__
+#define __WINT_TYPE__ int
+#endif
+
+#ifndef __WCHAR_TYPE__
+#define __WCHAR_TYPE__ int
+#endif
+
+void test(int i)
+{
+ /* All of these ctype functions should be const/pure and thus
+ eliminated. */
+#define TEST_IS_WCTYPE(FN) \
+ extern int FN(__WINT_TYPE__); \
+ extern void link_failure_##FN(void); \
+ if (FN(i) != FN(i)) \
+ link_failure_##FN()
+
+#define TEST_TO_WCTYPE(FN) \
+ extern __WINT_TYPE__ FN(__WINT_TYPE__); \
+ extern void link_failure_##FN(void); \
+ if (FN(i) != FN(i)) \
+ link_failure_##FN()
+
+
+#ifdef __OPTIMIZE__
+ TEST_IS_WCTYPE(iswalnum);
+ TEST_IS_WCTYPE(iswalpha);
+ TEST_IS_WCTYPE(iswblank);
+ TEST_IS_WCTYPE(iswcntrl);
+ TEST_IS_WCTYPE(iswdigit);
+ TEST_IS_WCTYPE(iswgraph);
+ TEST_IS_WCTYPE(iswlower);
+ TEST_IS_WCTYPE(iswprint);
+ TEST_IS_WCTYPE(iswpunct);
+ TEST_IS_WCTYPE(iswspace);
+ TEST_IS_WCTYPE(iswupper);
+ TEST_IS_WCTYPE(iswxdigit);
+ TEST_TO_WCTYPE(towlower);
+ TEST_TO_WCTYPE(towupper);
+#endif /* __OPTIMIZE__ */
+}
+
+int main (void)
+{
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/calleesave-sse.c b/gcc/testsuite/gcc.dg/torture/calleesave-sse.c
new file mode 100644
index 000000000..292791c72
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/calleesave-sse.c
@@ -0,0 +1,43 @@
+/* { dg-do run } */
+/* { dg-options "-fno-omit-frame-pointer" } */
+
+#define alloca __builtin_alloca
+extern void abort (void);
+
+__attribute__ ((noinline)) static double
+bar (double a, double b, double c, double d, char *h)
+{
+ *h = 0;
+ return a * b + b + c;
+}
+
+__attribute__ ((noinline)) static int
+boo (double a, double b, double c, double d)
+{
+ return c * b + a + b;
+}
+
+__attribute__ ((noinline)) static double
+foo (double a, double b, double c, double d)
+{
+ int aa = boo (b, c, d, a);
+ return bar (a, b, c, d, (char *) alloca (aa))
+ + bar (d, c, b, a, (char *) alloca (aa));
+}
+
+int main ()
+{
+ double a = 2.0, b = 3.0, c = 4.0, d = 5.0;
+ double r1, r2;
+ int aa;
+
+ aa = boo (b, c, d, a);
+ r1 = bar (a, b, c, d, (char *) alloca (aa))
+ + bar (d, c, b, a, (char *) alloca (aa));
+ r2 = foo (a, b, c, d);
+
+ if (r1 != r2)
+ abort ();
+ return 0;
+}
+
diff --git a/gcc/testsuite/gcc.dg/torture/cris-asm-mof-1.c b/gcc/testsuite/gcc.dg/torture/cris-asm-mof-1.c
new file mode 100644
index 000000000..5ebde5ed5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/cris-asm-mof-1.c
@@ -0,0 +1,36 @@
+/* { dg-do compile { target cris-*-* crisv32-*-* } } */
+/* { dg-skip-if "" { cris*-*-* } { "-march*" } { "" } } */
+/* { dg-options "-O2 -march=v10" } */
+/* { dg-final { scan-assembler "in-asm: .mof" } } */
+/* { dg-final { scan-assembler "out-asm: .mof" } } */
+/* { dg-final { scan-assembler "in2-asm: .mof" } } */
+/* { dg-final { scan-assembler "out2-asm: .mof" } } */
+
+unsigned int
+in (unsigned int i)
+{
+ register int i0 asm ("mof") = i;
+ asm ("in-asm: %0" : : "x" (i0));
+}
+
+unsigned int
+out (void)
+{
+ register int o asm ("mof");
+ asm ("out-asm: %0" : "=x" (o));
+ return o;
+}
+
+unsigned int
+in2 (unsigned int i)
+{
+ asm ("in2-asm: %0" : : "h" (i));
+}
+
+unsigned int
+out2 (void)
+{
+ unsigned int o;
+ asm ("out2-asm: %0" : "=h" (o));
+ return o;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/cris-volatile-1.c b/gcc/testsuite/gcc.dg/torture/cris-volatile-1.c
new file mode 100644
index 000000000..6b19852c2
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/cris-volatile-1.c
@@ -0,0 +1,72 @@
+/* Copyright (C) 2003 Free Software Foundation.
+ Check that size-optimizations for move insns (specifically peephole
+ optimizations) aren't applied to volatile objects in the CRIS port.
+ Origin: Hans-Peter Nilsson. */
+/* { dg-do compile { target cris-*-* crisv32-*-* } } */
+/* { dg-final { scan-assembler-not {movu\...\[} } } */
+/* { dg-final { scan-assembler-not {move\.[^d].\[} } } */
+/* { dg-final { scan-assembler-not {and\.[^d].\[} } } */
+/* { dg-final { scan-assembler-not {or\.[^d].\[} } } */
+
+static const unsigned long c = 0x0000FF00;
+unsigned long
+a1 (void)
+{
+ unsigned long m;
+ m = *(volatile unsigned long*) 0xb00000c8;
+ m &= c;
+ return m;
+}
+extern volatile unsigned long xx;
+unsigned long
+a2 (void)
+{
+ unsigned long m;
+ m = xx;
+ m &= c;
+ return m;
+}
+extern volatile unsigned long yy[];
+unsigned long
+a3 (void)
+{
+ unsigned long m;
+ m = yy[3];
+ m &= 0xfe00;
+ return m;
+}
+unsigned long
+ac1 (void)
+{
+ unsigned long m;
+ m = *(volatile unsigned long*) 0xb00000c8;
+ m &= 0xfe00;
+ return m;
+}
+extern volatile unsigned long xx;
+unsigned long
+ac2 (void)
+{
+ unsigned long m;
+ m = xx;
+ m &= 0xfe00;
+ return m;
+}
+extern volatile unsigned long yy[];
+unsigned long
+ac3 (void)
+{
+ unsigned long m;
+ m = yy[3];
+ m &= 0xfe00;
+ return m;
+}
+extern volatile unsigned long yy[];
+unsigned long
+oc3 (void)
+{
+ unsigned long m;
+ m = yy[3];
+ m |= ~0xf;
+ return m;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/darwin-cfstring-3.c b/gcc/testsuite/gcc.dg/torture/darwin-cfstring-3.c
new file mode 100644
index 000000000..2d755ec8d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/darwin-cfstring-3.c
@@ -0,0 +1,30 @@
+/* Test whether the __builtin__CFStringMakeConstantString
+ "function" generates compile-time objects with the correct layout. */
+/* Developed by Ziemowit Laski <zlaski@apple.com>. */
+
+/* { dg-do compile { target *-*-darwin* } } */
+/* { dg-options "-mconstant-cfstrings" } */
+
+typedef const struct __CFString *CFStringRef;
+
+#ifdef __CONSTANT_CFSTRINGS__
+#define CFSTR(STR) ((CFStringRef) __builtin___CFStringMakeConstantString (STR))
+#else
+#error __CONSTANT_CFSTRINGS__ not defined
+#endif
+
+extern int cond;
+extern const char *func(void);
+
+CFStringRef s0 = CFSTR("Hello" "there");
+
+void foo(void) {
+ const CFStringRef s1 = CFSTR("Str1");
+
+ s0 = s1;
+}
+
+/* { dg-final { scan-assembler "\\.long\[ \\t\]+___CFConstantStringClassReference\n\[ \\t\]*\\.long\[ \\t\]+1992\n\[ \\t\]*\\.long\[ \\t\]+LC.*\n\[ \\t\]*\\.long\[ \\t\]+4\n" { target { *-*-darwin* && { ! lp64 } } } } } */
+/* { dg-final { scan-assembler "\\.long\[ \\t\]+___CFConstantStringClassReference\n\[ \\t\]*\\.long\[ \\t\]+1992\n\[ \\t\]*\\.long\[ \\t\]+LC.*\n\[ \\t\]*\\.long\[ \\t\]+10\n" { target { *-*-darwin* && { ! lp64 } } } } } */
+/* { dg-final { scan-assembler ".quad\t___CFConstantStringClassReference\n\t.long\t1992\n\t.space 4\n\t.quad\t.*\n\t.quad\t4\n" { target { *-*-darwin* && { lp64 } } } } } */
+/* { dg-final { scan-assembler ".quad\t___CFConstantStringClassReference\n\t.long\t1992\n\t.space 4\n\t.quad\t.*\n\t.quad\t10\n" { target { *-*-darwin* && { lp64 } } } } } */
diff --git a/gcc/testsuite/gcc.dg/torture/dg-torture.exp b/gcc/testsuite/gcc.dg/torture/dg-torture.exp
new file mode 100644
index 000000000..cb91c791e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/dg-torture.exp
@@ -0,0 +1,7 @@
+# This harness is for tests that should be run at all optimisation levels.
+
+load_lib gcc-dg.exp
+
+dg-init
+gcc-dg-runtest [lsort [glob $srcdir/$subdir/*.c $srcdir/c-c++-common/torture/*.c]] ""
+dg-finish
diff --git a/gcc/testsuite/gcc.dg/torture/fp-int-convert-double.c b/gcc/testsuite/gcc.dg/torture/fp-int-convert-double.c
new file mode 100644
index 000000000..39ec3cde1
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/fp-int-convert-double.c
@@ -0,0 +1,18 @@
+/* Test floating-point conversions. Standard types and double. */
+/* Origin: Joseph Myers <joseph@codesourcery.com> */
+/* { dg-do run } */
+/* { dg-options "" } */
+
+#include <float.h>
+#include "fp-int-convert.h"
+
+int
+main (void)
+{
+ TEST_I_F(signed char, unsigned char, double, DBL_MANT_DIG);
+ TEST_I_F(signed short, unsigned short, double, DBL_MANT_DIG);
+ TEST_I_F(signed int, unsigned int, double, DBL_MANT_DIG);
+ TEST_I_F(signed long, unsigned long, double, DBL_MANT_DIG);
+ TEST_I_F(signed long long, unsigned long long, double, DBL_MANT_DIG);
+ exit (0);
+}
diff --git a/gcc/testsuite/gcc.dg/torture/fp-int-convert-float.c b/gcc/testsuite/gcc.dg/torture/fp-int-convert-float.c
new file mode 100644
index 000000000..7fca1df7a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/fp-int-convert-float.c
@@ -0,0 +1,18 @@
+/* Test floating-point conversions. Standard types and float. */
+/* Origin: Joseph Myers <joseph@codesourcery.com> */
+/* { dg-do run } */
+/* { dg-options "" } */
+
+#include <float.h>
+#include "fp-int-convert.h"
+
+int
+main (void)
+{
+ TEST_I_F(signed char, unsigned char, float, FLT_MANT_DIG);
+ TEST_I_F(signed short, unsigned short, float, FLT_MANT_DIG);
+ TEST_I_F(signed int, unsigned int, float, FLT_MANT_DIG);
+ TEST_I_F(signed long, unsigned long, float, FLT_MANT_DIG);
+ TEST_I_F(signed long long, unsigned long long, float, FLT_MANT_DIG);
+ exit (0);
+}
diff --git a/gcc/testsuite/gcc.dg/torture/fp-int-convert-float128-timode.c b/gcc/testsuite/gcc.dg/torture/fp-int-convert-float128-timode.c
new file mode 100644
index 000000000..8318f8ad8
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/fp-int-convert-float128-timode.c
@@ -0,0 +1,15 @@
+/* Test floating-point conversions. __float128 type with TImode. */
+/* Origin: Joseph Myers <joseph@codesourcery.com> */
+/* { dg-do run { target i?86-*-* x86_64-*-* ia64-*-* } } */
+/* { dg-options "" } */
+
+#include "fp-int-convert.h"
+
+#define FLOAT128_MANT_DIG 113
+
+int
+main (void)
+{
+ TEST_I_F(TItype, UTItype, __float128, FLOAT128_MANT_DIG);
+ exit (0);
+}
diff --git a/gcc/testsuite/gcc.dg/torture/fp-int-convert-float128.c b/gcc/testsuite/gcc.dg/torture/fp-int-convert-float128.c
new file mode 100644
index 000000000..bc5e5adeb
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/fp-int-convert-float128.c
@@ -0,0 +1,19 @@
+/* Test floating-point conversions. __float128 type. */
+/* Origin: Joseph Myers <joseph@codesourcery.com> */
+/* { dg-do run { target i?86-*-* x86_64-*-* ia64-*-* } } */
+/* { dg-options "" } */
+
+#include "fp-int-convert.h"
+
+#define FLOAT128_MANT_DIG 113
+
+int
+main (void)
+{
+ TEST_I_F(signed char, unsigned char, __float128, FLOAT128_MANT_DIG);
+ TEST_I_F(signed short, unsigned short, __float128, FLOAT128_MANT_DIG);
+ TEST_I_F(signed int, unsigned int, __float128, FLOAT128_MANT_DIG);
+ TEST_I_F(signed long, unsigned long, __float128, FLOAT128_MANT_DIG);
+ TEST_I_F(signed long long, unsigned long long, __float128, FLOAT128_MANT_DIG);
+ exit (0);
+}
diff --git a/gcc/testsuite/gcc.dg/torture/fp-int-convert-float80-timode.c b/gcc/testsuite/gcc.dg/torture/fp-int-convert-float80-timode.c
new file mode 100644
index 000000000..5b9bb706c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/fp-int-convert-float80-timode.c
@@ -0,0 +1,16 @@
+/* Test floating-point conversions. __float80 type with TImode. */
+/* Origin: Joseph Myers <joseph@codesourcery.com> */
+/* { dg-do run { target i?86-*-* x86_64-*-* ia64-*-* } } */
+/* { dg-options "" } */
+/* { dg-options "-mmmx" { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */
+
+#include "fp-int-convert.h"
+
+#define FLOAT80_MANT_DIG 64
+
+int
+main (void)
+{
+ TEST_I_F(TItype, UTItype, __float80, FLOAT80_MANT_DIG);
+ exit (0);
+}
diff --git a/gcc/testsuite/gcc.dg/torture/fp-int-convert-float80.c b/gcc/testsuite/gcc.dg/torture/fp-int-convert-float80.c
new file mode 100644
index 000000000..3e25f904d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/fp-int-convert-float80.c
@@ -0,0 +1,19 @@
+/* Test floating-point conversions. __float80 type. */
+/* Origin: Joseph Myers <joseph@codesourcery.com> */
+/* { dg-do run { target i?86-*-* x86_64-*-* ia64-*-* } } */
+/* { dg-options "" } */
+
+#include "fp-int-convert.h"
+
+#define FLOAT80_MANT_DIG 64
+
+int
+main (void)
+{
+ TEST_I_F(signed char, unsigned char, __float80, FLOAT80_MANT_DIG);
+ TEST_I_F(signed short, unsigned short, __float80, FLOAT80_MANT_DIG);
+ TEST_I_F(signed int, unsigned int, __float80, FLOAT80_MANT_DIG);
+ TEST_I_F(signed long, unsigned long, __float80, FLOAT80_MANT_DIG);
+ TEST_I_F(signed long long, unsigned long long, __float80, FLOAT80_MANT_DIG);
+ exit (0);
+}
diff --git a/gcc/testsuite/gcc.dg/torture/fp-int-convert-long-double.c b/gcc/testsuite/gcc.dg/torture/fp-int-convert-long-double.c
new file mode 100644
index 000000000..bb189a34c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/fp-int-convert-long-double.c
@@ -0,0 +1,18 @@
+/* Test floating-point conversions. Standard types and long double. */
+/* Origin: Joseph Myers <joseph@codesourcery.com> */
+/* { dg-do run } */
+/* { dg-options "" } */
+
+#include <float.h>
+#include "fp-int-convert.h"
+
+int
+main (void)
+{
+ TEST_I_F(signed char, unsigned char, long double, LDBL_MANT_DIG);
+ TEST_I_F(signed short, unsigned short, long double, LDBL_MANT_DIG);
+ TEST_I_F(signed int, unsigned int, long double, LDBL_MANT_DIG);
+ TEST_I_F(signed long, unsigned long, long double, LDBL_MANT_DIG);
+ TEST_I_F(signed long long, unsigned long long, long double, LDBL_MANT_DIG);
+ exit (0);
+}
diff --git a/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode.c b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode.c
new file mode 100644
index 000000000..3a60d01ff
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode.c
@@ -0,0 +1,21 @@
+/* Test floating-point conversions. TImode types. */
+/* Origin: Joseph Myers <joseph@codesourcery.com> */
+/* { dg-do run } */
+/* { dg-options "" } */
+
+#include <float.h>
+#include "fp-int-convert.h"
+
+int
+main (void)
+{
+ TEST_I_F(TItype, UTItype, float, FLT_MANT_DIG);
+ TEST_I_F(TItype, UTItype, double, DBL_MANT_DIG);
+ /* Disable the long double tests when using IBM Extended Doubles.
+ They have variable precision, but constants calculated by gcc's
+ real.c assume fixed precision. */
+#if DBL_MANT_DIG != LDBL_MANT_DIG && LDBL_MANT_DIG != 106
+ TEST_I_F(TItype, UTItype, long double, LDBL_MANT_DIG);
+#endif
+ exit (0);
+}
diff --git a/gcc/testsuite/gcc.dg/torture/fp-int-convert.h b/gcc/testsuite/gcc.dg/torture/fp-int-convert.h
new file mode 100644
index 000000000..61d2c0199
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/fp-int-convert.h
@@ -0,0 +1,89 @@
+/* Test floating-point conversions. */
+/* Origin: Joseph Myers <joseph@codesourcery.com> */
+
+#include <limits.h>
+extern void abort (void);
+extern void exit (int);
+
+/* Not all platforms support TImode integers; logic as in
+ gcc.dg/titype-1.c. */
+#if (defined(__LP64__) && !defined(__hppa__)) || defined(_WIN64) || defined(__SPU__)
+typedef int TItype __attribute__ ((mode (TI)));
+typedef unsigned int UTItype __attribute__ ((mode (TI)));
+#else
+typedef long TItype;
+typedef unsigned long UTItype;
+#endif
+
+/* TEST_I_F(I, U, F, P) tests conversions between the pair of signed
+ and unsigned integer types I and U and the floating-point type F,
+ where P is the binary precision of the floating point type. We
+ test conversions of the values 0, 1, 0x7...f, 0x8...0, 0xf...f. We
+ also test conversions of values half way inbetween two
+ representable values (rounding both ways), just above half way, and
+ just below half way. */
+#define TEST_I_F(I, U, F, P) \
+do { \
+ TEST_I_F_VAL (I, F, (I)0, 1); \
+ TEST_I_F_VAL (I, F, (I)1, 1); \
+ TEST_I_F_VAL (I, F, (I)(((U)~(U)0) >> 1), P_OK1 (P, I)); \
+ TEST_I_F_VAL (I, F, (I)(U)~(((U)~(U)0) >> 1), 1); \
+ TEST_I_F_VAL (I, F, (I)(U)~(U)0, P_OK (P, I)); \
+ TEST_I_F_VAL (I, F, HVAL0S (P, I), P_OK (P, I)); \
+ TEST_I_F_VAL (I, F, HVAL0S (P, I) + 1, P_OK (P, I)); \
+ TEST_I_F_VAL (I, F, HVAL0S (P, I) - 1, P_OK (P, I)); \
+ TEST_I_F_VAL (I, F, HVAL1S (P, I), P_OK (P, I)); \
+ TEST_I_F_VAL (I, F, HVAL1S (P, I) + 1, P_OK (P, I)); \
+ TEST_I_F_VAL (I, F, HVAL1S (P, I) - 1, P_OK (P, I)); \
+ TEST_I_F_VAL (I, F, -HVAL0S (P, I), P_OK (P, I)); \
+ TEST_I_F_VAL (I, F, -HVAL0S (P, I) + 1, P_OK (P, I)); \
+ TEST_I_F_VAL (I, F, -HVAL0S (P, I) - 1, P_OK (P, I)); \
+ TEST_I_F_VAL (I, F, -HVAL1S (P, I), P_OK (P, I)); \
+ TEST_I_F_VAL (I, F, -HVAL1S (P, I) + 1, P_OK (P, I)); \
+ TEST_I_F_VAL (I, F, -HVAL1S (P, I) - 1, P_OK (P, I)); \
+ TEST_I_F_VAL (U, F, (U)0, 1); \
+ TEST_I_F_VAL (U, F, (U)1, 1); \
+ TEST_I_F_VAL (U, F, (U)(((U)~(U)0) >> 1), P_OK1 (P, U)); \
+ TEST_I_F_VAL (U, F, (U)~(((U)~(U)0) >> 1), 1); \
+ TEST_I_F_VAL (U, F, (U)~(U)0, P_OK (P, U)); \
+ TEST_I_F_VAL (U, F, HVAL0U (P, U), P_OK (P, U)); \
+ TEST_I_F_VAL (U, F, HVAL0U (P, U) + 1, P_OK (P, U)); \
+ TEST_I_F_VAL (U, F, HVAL0U (P, U) - 1, P_OK (P, U)); \
+ TEST_I_F_VAL (U, F, HVAL1U (P, U), P_OK (P, U)); \
+ TEST_I_F_VAL (U, F, HVAL1U (P, U) + 1, P_OK (P, U)); \
+ TEST_I_F_VAL (U, F, HVAL1U (P, U) - 1, P_OK (P, U)); \
+} while (0)
+
+#define P_OK(P, T) ((P) >= sizeof(T) * CHAR_BIT)
+#define P_OK1(P, T) ((P) >= sizeof(T) * CHAR_BIT - 1)
+#define HVAL0U(P, U) (U)(P_OK (P, U) \
+ ? (U)1 \
+ : (((U)1 << (sizeof(U) * CHAR_BIT - 1)) \
+ + ((U)1 << (sizeof(U) * CHAR_BIT - 1 - P))))
+#define HVAL1U(P, U) (U)(P_OK (P, U) \
+ ? (U)1 \
+ : (((U)1 << (sizeof(U) * CHAR_BIT - 1)) \
+ + ((U)3 << (sizeof(U) * CHAR_BIT - 1 - P))))
+#define HVAL0S(P, S) (S)(P_OK1 (P, S) \
+ ? (S)1 \
+ : (((S)1 << (sizeof(S) * CHAR_BIT - 2)) \
+ + ((S)1 << (sizeof(S) * CHAR_BIT - 2 - P))))
+#define HVAL1S(P, S) (S)(P_OK1 (P, S) \
+ ? (S)1 \
+ : (((S)1 << (sizeof(S) * CHAR_BIT - 2)) \
+ + ((S)3 << (sizeof(S) * CHAR_BIT - 2 - P))))
+
+#define TEST_I_F_VAL(IT, FT, VAL, PREC_OK) \
+do { \
+ static volatile IT ivin, ivout; \
+ static volatile FT fv1, fv2; \
+ ivin = (VAL); \
+ fv1 = (VAL); \
+ fv2 = ivin; \
+ ivout = fv2; \
+ if (ivin != (VAL) \
+ || ((PREC_OK) && ivout != ivin) \
+ || ((PREC_OK) && ivout != (VAL)) \
+ || fv1 != (VAL) || fv2 != (VAL) || fv1 != fv2) \
+ abort (); \
+} while (0)
diff --git a/gcc/testsuite/gcc.dg/torture/inline-1.c b/gcc/testsuite/gcc.dg/torture/inline-1.c
new file mode 100644
index 000000000..c7144ca68
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/inline-1.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-options "--param ggc-min-heapsize=0 --param ggc-min-expand=0" } */
+/* This used to ICE because we forgot to update the statement after folding
+ and the eh info. */
+/* PR tree-opt/30385 */
+
+static inline void g(int t)
+{
+ int a;
+ while (a < f())
+ ;
+}
+void h(int t)
+{
+ g(t);
+}
diff --git a/gcc/testsuite/gcc.dg/torture/inline-2.c b/gcc/testsuite/gcc.dg/torture/inline-2.c
new file mode 100644
index 000000000..0d341bfad
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/inline-2.c
@@ -0,0 +1,35 @@
+/* { dg-do link } */
+
+extern inline void foo2 (void) __attribute__((always_inline,gnu_inline));
+extern inline void foo1 (void) __attribute__((always_inline,gnu_inline));
+void bar1 (void);
+void bar2 (void);
+
+extern inline void __attribute__((always_inline,gnu_inline))
+foo2 (void)
+{
+ bar2 ();
+}
+
+void
+bar1 (void)
+{
+ foo2 ();
+}
+
+void
+bar2 (void)
+{
+ foo1 ();
+}
+
+extern inline void __attribute__((always_inline,gnu_inline))
+foo1 (void)
+{
+ bar1 ();
+}
+
+int main()
+{
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/ipa-pta-1.c b/gcc/testsuite/gcc.dg/torture/ipa-pta-1.c
new file mode 100644
index 000000000..6d0d03261
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/ipa-pta-1.c
@@ -0,0 +1,46 @@
+/* { dg-do compile { target { nonpic } } } */
+/* { dg-options "-fipa-pta -fdump-ipa-pta" } */
+/* { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */
+
+struct X { char x; char y; };
+
+char *q;
+
+static void __attribute__((noinline))
+bar (char *p)
+{
+ q = p;
+}
+
+void test1 (char a1, char b, char c, char d, char e, char f, char g, char h)
+{
+ char *p = &a1;
+ p++;
+ bar (p);
+}
+
+void test2 (struct X a2, char b, char c, char d, char e, char f, char g, char h)
+{
+ char *p = &a2.x;
+ p++;
+ bar (p);
+}
+
+void test3 (struct X a3, char b, char c, char d, char e, char f, char g, char h)
+{
+ char *p = &a3.y;
+ bar (p);
+}
+
+void test4 (int a4, char b, char c, char d, char e, char f, char g, char h)
+{
+ char *p = (char *)&a4;
+ p++;
+ p++;
+ p++;
+ p++;
+ bar (p);
+}
+
+/* { dg-final { scan-ipa-dump "bar.arg0 = { test4.arg0 test3.arg0 test2.arg0 test1.arg0 }" "pta" } } */
+/* { dg-final { cleanup-ipa-dump "pta" } } */
diff --git a/gcc/testsuite/gcc.dg/torture/ipa-pta-2.c b/gcc/testsuite/gcc.dg/torture/ipa-pta-2.c
new file mode 100644
index 000000000..768c99e82
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/ipa-pta-2.c
@@ -0,0 +1,24 @@
+/* { dg-do run } */
+/* { dg-options "-fipa-pta" } */
+
+int **x;
+
+static int __attribute__((noinline,noclone))
+foo (int **p)
+{
+ int a = 1;
+ **p = 0;
+ *x = &a;
+ return **p;
+}
+
+extern void abort (void);
+int main()
+{
+ int b;
+ int *p = &b;
+ x = &p;
+ if (foo (&p) != 1)
+ abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/mips-clobber-at.c b/gcc/testsuite/gcc.dg/torture/mips-clobber-at.c
new file mode 100644
index 000000000..7f936984a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/mips-clobber-at.c
@@ -0,0 +1,4 @@
+/* "$1" used to be mapped to the internal frame pointer. */
+/* { dg-do compile { target mips*-*-* } } */
+/* { dg-options "" } */
+int foo () { asm volatile ("#" ::: "$1"); }
diff --git a/gcc/testsuite/gcc.dg/torture/mips-div-1.c b/gcc/testsuite/gcc.dg/torture/mips-div-1.c
new file mode 100644
index 000000000..6345000fe
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/mips-div-1.c
@@ -0,0 +1,9 @@
+/* Check that hard-float MIPS code doesn't use library calls for 1.0/x. */
+/* { dg-options "-fno-delayed-branch" } */
+/* { dg-do compile { target mips*-*-* } } */
+
+float f1 (float x) { return 1.0f / x; }
+double f2 (double x) { return 1.0 / x; }
+
+/* { dg-final { scan-assembler-not {lwc1.*__divsf3} } } */
+/* { dg-final { scan-assembler-not {ldc1.*__divdf3} } } */
diff --git a/gcc/testsuite/gcc.dg/torture/mips-hilo-2.c b/gcc/testsuite/gcc.dg/torture/mips-hilo-2.c
new file mode 100644
index 000000000..dbe949307
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/mips-hilo-2.c
@@ -0,0 +1,27 @@
+/* Due to a reload inheritance bug, the asm statement in f() would be passed
+ the low part of u.ll on little-endian 32-bit targets. */
+/* { dg-do run { target mips*-*-* } } */
+
+extern void abort (void);
+extern void exit (int);
+
+unsigned int g;
+
+unsigned __attribute__ ((nomips16)) long long f (unsigned int x)
+{
+ union { unsigned long long ll; unsigned int parts[2]; } u;
+
+ u.ll = ((unsigned long long) x * x);
+ asm ("mflo\t%0" : "=r" (g) : "l" (u.parts[1]));
+ return u.ll;
+}
+
+int __attribute__ ((nomips16)) main ()
+{
+ union { unsigned long long ll; unsigned int parts[2]; } u;
+
+ u.ll = f (0x12345678);
+ if (g != u.parts[1])
+ abort ();
+ exit (0);
+}
diff --git a/gcc/testsuite/gcc.dg/torture/mips-sdata-1.c b/gcc/testsuite/gcc.dg/torture/mips-sdata-1.c
new file mode 100644
index 000000000..8ffd4d848
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/mips-sdata-1.c
@@ -0,0 +1,10 @@
+/* Check that sdata-accesses are applied regardless of size or ABI. */
+/* { dg-options -mexplicit-relocs } */
+/* { dg-do compile { target mips*-*-elf* } } */
+
+struct s { int x[4]; };
+struct s my_struct __attribute__((__section__(".sdata")));
+
+int f() { return my_struct.x[0]; }
+
+/* { dg-final { scan-assembler {gp_?rel\(my_struct} } } */
diff --git a/gcc/testsuite/gcc.dg/torture/nested-fn-1.c b/gcc/testsuite/gcc.dg/torture/nested-fn-1.c
new file mode 100644
index 000000000..99e852344
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/nested-fn-1.c
@@ -0,0 +1,74 @@
+/* PR middle-end/15345, c/16450 */
+/* Test whether unused nested functions aren't emitted into the assembly. */
+/* { dg-do compile } */
+/* { dg-options "-g0" } */
+/* { dg-require-effective-target trampolines } */
+
+int
+fn1 (int x)
+{
+ int i = x;
+ inline __attribute__((always_inline)) int
+ should_not_appear1 (void)
+ {
+ return i;
+ }
+ return should_not_appear1 ();
+}
+
+int
+fn2 (int x)
+{
+ int i = x;
+ inline __attribute__((always_inline)) int
+ should_not_appear2 (void)
+ {
+ return i;
+ }
+ return x;
+}
+
+extern void check (void *p);
+
+int
+fn3 (int x)
+{
+ int i = x;
+ inline int
+ should_appear1 (void)
+ {
+ char *p = __builtin_alloca (i);
+ check (p);
+ return i;
+ }
+ return should_appear1 ();
+}
+
+int
+fn4 (int x)
+{
+ int i = x;
+ inline int
+ should_not_appear3 (void)
+ {
+ char *p = __builtin_alloca (i);
+ check (p);
+ return i;
+ }
+ return 0 ? should_not_appear3 () : 1;
+}
+
+int
+fn5 (int x)
+{
+ int i = x;
+ inline int
+ should_appear2 (void)
+ {
+ return i;
+ }
+ check (should_appear2);
+ return i;
+}
+
+/* { dg-final { scan-assembler-not "should_not_appear" } } */
diff --git a/gcc/testsuite/gcc.dg/torture/pr16104-1.c b/gcc/testsuite/gcc.dg/torture/pr16104-1.c
new file mode 100644
index 000000000..ad5eda65f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr16104-1.c
@@ -0,0 +1,79 @@
+/* PR rtl-optimization/16104 */
+/* { dg-do run { target i?86-*-* x86_64-*-* } } */
+/* { dg-options "-msse2" } */
+/* { dg-require-effective-target sse2_runtime } */
+
+extern void abort (void);
+
+typedef int V2SI __attribute__ ((vector_size (8)));
+typedef unsigned int V2USI __attribute__ ((vector_size (8)));
+typedef short V2HI __attribute__ ((vector_size (4)));
+typedef unsigned int V2UHI __attribute__ ((vector_size (4)));
+
+int
+test1 (void)
+{
+ return (long long) (V2SI) 0LL;
+}
+
+int
+test2 (V2SI x)
+{
+ return (long long) x;
+}
+
+V2SI
+test3 (void)
+{
+ return (V2SI) (long long) (int) (V2HI) 0;
+}
+
+V2SI
+test4 (V2HI x)
+{
+ return (V2SI) (long long) (int) x;
+}
+
+V2SI
+test5 (V2USI x)
+{
+ return (V2SI) x;
+}
+
+void
+__attribute__ ((noinline))
+do_test (void)
+{
+ if (sizeof (short) != 2 || sizeof (int) != 4 || sizeof (long long) != 8)
+ return;
+
+ if (test1 () != 0)
+ abort ();
+
+ V2SI x = { 2, 2 };
+ if (test2 (x) != 2)
+ abort ();
+
+ union { V2SI x; int y[2]; V2USI z; long long l; } u;
+ u.x = test3 ();
+ if (u.y[0] != 0 || u.y[1] != 0)
+ abort ();
+
+ V2HI y = { 4, 4 };
+ union { V2SI x; long long y; } v;
+ v.x = test4 (y);
+ if (v.y != 0x40004)
+ abort ();
+
+ V2USI z = { 6, 6 };
+ u.x = test5 (z);
+ if (u.y[0] != 6 || u.y[1] != 6)
+ abort ();
+}
+
+int
+main (void)
+{
+ do_test ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr17526.c b/gcc/testsuite/gcc.dg/torture/pr17526.c
new file mode 100644
index 000000000..58b479143
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr17526.c
@@ -0,0 +1,27 @@
+/* { dg-do run } */
+/* { dg-options "-fno-pcc-struct-return" { target i?86-*-* } } */
+
+void abort(void);
+
+typedef struct { int i; } A;
+
+A __attribute__((noinline))
+foo(void)
+{
+ A a = { -1 };
+ return a;
+}
+
+void __attribute__((noinline))
+bar(A *p)
+{
+ *p = foo();
+}
+
+int main(void)
+{
+ A a;
+ bar(&a);
+ if (a.i != -1) abort();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr17933-1.c b/gcc/testsuite/gcc.dg/torture/pr17933-1.c
new file mode 100644
index 000000000..02c597b0a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr17933-1.c
@@ -0,0 +1,14 @@
+/* PR rtl-optimization/17933.
+ Test-case from the ObjC test-suite, execute/class_self-2.m,
+ translated to C from and reduced by Andrew Pinski. */
+
+struct d
+{ int a; };
+void abort(void);
+typedef struct d (*f) (int i);
+f ff(void);
+void test1()
+{
+ f t = ff();
+ t(0);
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr18582-1.c b/gcc/testsuite/gcc.dg/torture/pr18582-1.c
new file mode 100644
index 000000000..619593905
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr18582-1.c
@@ -0,0 +1,24 @@
+/* { dg-do compile { target i?86-*-* x86_64-*-* } } */
+/* { dg-options "-msse3" } */
+typedef char v16qi __attribute__((vector_size (16)));
+typedef float v4sf __attribute__((vector_size (16)));
+typedef double v2df __attribute__((vector_size (16)));
+
+extern char ca[];
+extern float fa[];
+extern double da[];
+
+extern v16qi cva[];
+extern v4sf fva[];
+extern v2df dva[];
+
+void
+foo (void)
+{
+ cva[0] = __builtin_ia32_loaddqu (ca);
+ cva[0] = __builtin_ia32_lddqu (ca);
+
+ fva[0] = __builtin_ia32_loadups (fa);
+
+ dva[0] = __builtin_ia32_loadupd (da);
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr19462-1.c b/gcc/testsuite/gcc.dg/torture/pr19462-1.c
new file mode 100644
index 000000000..8e140356f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr19462-1.c
@@ -0,0 +1,56 @@
+/* { dg-do compile } */
+/* PR rtl-optimization/19462
+ Delayed branch bug: return insns generated in presence of
+ current_function_epilogue_delay_list. See also PR target/7042. */
+
+/* The test is from newlib/libc/string/wcscspn.c, which has the following
+ copyright and licensing notice, which by inclusion this file supposedly
+ complies with:
+
+ * Copyright (c)1999 Citrus Project,
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE. */
+
+
+unsigned long
+wcscspn(const long *s, const long *set)
+{
+ const long *p;
+ const long *q;
+
+ p = s;
+ while (*p)
+ {
+ q = set;
+ while (*q)
+ {
+ if (*p == *q)
+ goto done;
+ q++;
+ }
+ p++;
+ }
+
+done:
+ return (p - s);
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr19683-1.c b/gcc/testsuite/gcc.dg/torture/pr19683-1.c
new file mode 100644
index 000000000..05bf17418
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr19683-1.c
@@ -0,0 +1,42 @@
+/* From PR rtl-optimization/19683. On little-endian MIPS targets,
+ reload would incorrectly inherit the high part of the multiplication
+ result. */
+/* { dg-do run { target mips*-*-* } } */
+
+extern void abort (void);
+extern void exit (int);
+
+#define REPEAT10(X, Y) \
+ X(Y##0); X(Y##1); X(Y##2); X(Y##3); X(Y##4); \
+ X(Y##5); X(Y##6); X(Y##7); X(Y##8); X(Y##9)
+
+#define REPEAT30(X) REPEAT10 (X, 0); REPEAT10 (X, 1); REPEAT10 (X, 2)
+#define IN(X) unsigned int x##X = ptr[0]
+#define OUT(X) ptr[0] = x##X
+
+union u { unsigned long long ll; unsigned int i[2]; };
+
+unsigned int __attribute__ ((nomips16))
+foo (volatile unsigned int *ptr)
+{
+ union u u;
+ int result;
+
+ u.ll = (unsigned long long) ptr[0] * ptr[0];
+ REPEAT30 (IN);
+ REPEAT30 (OUT);
+ asm ("#" : "=l" (result) : "l" (u.i[1]));
+ return result;
+}
+
+int __attribute__ ((nomips16))
+main (void)
+{
+ unsigned int array[] = { 1000 * 1000 * 1000 };
+ union u u;
+
+ u.ll = (unsigned long long) array[0] * array[0];
+ if (foo (array) != u.i[1])
+ abort ();
+ exit (0);
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr20314-1.c b/gcc/testsuite/gcc.dg/torture/pr20314-1.c
new file mode 100644
index 000000000..8a69c2dca
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr20314-1.c
@@ -0,0 +1,56 @@
+/* PR inline-asm/20314 */
+/* { dg-do compile { target i?86-*-* x86_64-*-* powerpc*-*-* ia64-*-* } } */
+
+int
+f1 (void)
+{
+ int x = 4, y;
+ __asm__ volatile ("" : "+r,r" (x), "=r,r" (y)
+ : "%r,r" (x), "m,r" (8), "r,r" (2));
+ return x;
+}
+
+int
+f2 (void)
+{
+ int x = 4, y;
+ __asm__ volatile ("" : "=r,r" (x), "=r,r" (y)
+ : "%0,0" (x), "m,r" (8), "r,r" (2));
+ return x;
+}
+
+int
+f3 (void)
+{
+ int x = 4, y;
+ __asm__ volatile ("" : "+r,r" (x), "=r,r" (y)
+ : "%m,r" (8), "r,r" (2));
+ return x;
+}
+
+int
+f4 (void)
+{
+ int x = 4, y;
+ __asm__ volatile ("" : "+r" (x), "=r" (y)
+ : "r" (x), "r" (8), "r" (2));
+ return x;
+}
+
+int
+f5 (void)
+{
+ int x = 4, y;
+ __asm__ volatile ("" : "=r" (x), "=r" (y)
+ : "0" (x), "r" (8), "r" (2));
+ return x;
+}
+
+int
+f6 (void)
+{
+ int x = 4, y;
+ __asm__ volatile ("" : "+r" (x), "=r" (y)
+ : "r" (8), "r" (2));
+ return x;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr20314-2.c b/gcc/testsuite/gcc.dg/torture/pr20314-2.c
new file mode 100644
index 000000000..8185218c1
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr20314-2.c
@@ -0,0 +1,47 @@
+/* PR inline-asm/20314 */
+/* { dg-do compile { target { { i?86-*-* x86_64-*-* } && lp64 } } } */
+/* { dg-do compile { target ia64-*-* powerpc*-*-* } } */
+
+int a, b, c, d, e, f, g, h, i, j, k, l;
+
+void
+f1 (void)
+{
+ __asm__ volatile (""
+ : [a] "+r" (a), [b] "+r" (b), [c] "+r" (c), [d] "+r" (d),
+ [e] "+r" (e), [f] "+r" (f), [g] "+r" (g), [h] "+r" (h),
+ [i] "+r" (i), [j] "+r" (j), [k] "+r" (k), [l] "+r" (l));
+}
+
+void
+f2 (void)
+{
+ __asm__ volatile (""
+ : [a] "+r,m" (a), [b] "+r,m" (b), [c] "+r,m" (c), [d] "+r,m" (d),
+ [e] "+r,m" (e), [f] "+r,m" (f), [g] "+r,m" (g), [h] "+r,m" (h),
+ [i] "+r,m" (i), [j] "+r,m" (j), [k] "+r,m" (k), [l] "+r,m" (l));
+}
+
+void
+f3 (void)
+{
+ __asm__ volatile (""
+ : [a] "=r" (a), [b] "=r" (b), [c] "=r" (c), [d] "=r" (d),
+ [e] "=r" (e), [f] "=r" (f), [g] "=r" (g), [h] "=r" (h),
+ [i] "=r" (i), [j] "=r" (j), [k] "=r" (k), [l] "=r" (l)
+ : "[a]" (a), "[b]" (b), "[c]" (c), "[d]" (d),
+ "[e]" (e), "[f]" (f), "[g]" (g), "[h]" (h),
+ "[i]" (i), "[j]" (j), "[k]" (k), "[l]" (l));
+}
+
+void
+f4 (void)
+{
+ __asm__ volatile (""
+ : [a] "=r,m" (a), [b] "=r,m" (b), [c] "=r,m" (c), [d] "=r,m" (d),
+ [e] "=r,m" (e), [f] "=r,m" (f), [g] "=r,m" (g), [h] "=r,m" (h),
+ [i] "=r,m" (i), [j] "=r,m" (j), [k] "=r,m" (k), [l] "=r,m" (l)
+ : "[a],m" (a), "[b],m" (b), "[c],m" (c), "[d],m" (d),
+ "[e],m" (e), "[f],m" (f), "[g],m" (g), "[h],m" (h),
+ "[i],m" (i), "[j],m" (j), "[k],m" (k), "[l],m" (l));
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr21817-1.c b/gcc/testsuite/gcc.dg/torture/pr21817-1.c
new file mode 100644
index 000000000..d90d3239c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr21817-1.c
@@ -0,0 +1,16 @@
+/* hppa*-*-hpux* needs -fno-common so that value can be given a 16
+ byte alignment. */
+
+/* { dg-do compile } */
+/* { dg-options "-fno-common" { target { hppa*-*-hpux* } } } */
+
+typedef float v4sf __attribute__((vector_size(16)));
+v4sf value;
+void foo(void)
+{
+ unsigned int band;
+ for(band=0; band < 2; band++)
+ {
+ value += (v4sf){1e9f,1e9f,1e9f,1e9f};
+ }
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr23424-1.c b/gcc/testsuite/gcc.dg/torture/pr23424-1.c
new file mode 100644
index 000000000..91950d77a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr23424-1.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+extern char *x;
+extern void foo (void);
+void f (char *s, char *se, char *mp, char *y)
+{
+ while (s != se)
+ {
+ char *p;
+ foo ();
+ p = s + *mp;
+ *y++ = *p;
+ s = p;
+ }
+
+ x = s;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr23821.c b/gcc/testsuite/gcc.dg/torture/pr23821.c
new file mode 100644
index 000000000..7632d8425
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr23821.c
@@ -0,0 +1,29 @@
+/* { dg-do compile } */
+/* { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */
+/* At -O1 DOM threads a jump in a non-optimal way which leads to
+ the bogus propagation. */
+/* { dg-skip-if "" { *-*-* } { "-O1" } { "" } } */
+/* { dg-options "-fdump-tree-ivcanon-details" } */
+
+int a[199];
+
+extern void abort (void);
+
+int
+main ()
+{
+ int i, x;
+ for (i = 0; i < 199; i++)
+ {
+ x = a[i];
+ if (x != i)
+ abort ();
+ }
+ return 0;
+}
+
+/* Verify that we do not propagate the equivalence x == i into the
+ induction variable increment. */
+
+/* { dg-final { scan-tree-dump "Added canonical iv" "ivcanon" } } */
+/* { dg-final { cleanup-tree-dump "ivcanon" } } */
diff --git a/gcc/testsuite/gcc.dg/torture/pr24257.c b/gcc/testsuite/gcc.dg/torture/pr24257.c
new file mode 100644
index 000000000..d685df63d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr24257.c
@@ -0,0 +1,26 @@
+/* { dg-do compile } */
+/* { dg-options "-fgcse -fgcse-sm" } */
+
+typedef struct A {
+ int buf, left;
+} A;
+
+static void flush(A *s, int n)
+{
+ s->buf <<= n;
+
+ while (s->left < 32) {
+ s->buf <<= 8;
+ s->left += 8;
+ }
+
+ s->buf=0;
+}
+
+void oof(A *s, int n)
+{
+ s->buf = n;
+ s->left = n;
+
+ flush(s, n);
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr24626-1.c b/gcc/testsuite/gcc.dg/torture/pr24626-1.c
new file mode 100644
index 000000000..331c55ec3
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr24626-1.c
@@ -0,0 +1,27 @@
+/* { dg-do compile } */
+
+typedef long
+(*bla)(int *node);
+
+static long F2(void *tree, long blk, bla after_node_func)
+{
+ long call_result = 0;
+ int *node;
+
+
+ if (call_result = after_node_func(node))
+ goto error_free_node;
+
+ T(node);
+ return 0;
+
+error_free_node:
+ T(node);
+error:
+ return call_result;
+}
+
+long F1(void *tree)
+{
+ return F2(tree, F3(tree), (void *)0);
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr24626-2.c b/gcc/testsuite/gcc.dg/torture/pr24626-2.c
new file mode 100644
index 000000000..e48d3b31c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr24626-2.c
@@ -0,0 +1,54 @@
+/* { dg-do compile } */
+
+typedef unsigned int u_int8_t __attribute__ ((__mode__ (__QI__)));
+typedef unsigned int u_int32_t __attribute__ ((__mode__ (__SI__)));
+typedef u_int32_t db_pgno_t;
+typedef struct __db DB;
+typedef struct __db_env DB_ENV;
+typedef struct __db_mpoolfile DB_MPOOLFILE;
+typedef struct __dbc DBC;
+struct __db {
+ DB_MPOOLFILE *mpf;
+ db_pgno_t meta_pgno;
+ struct __cq_aq {
+ } s_links;
+};
+struct __db_env {
+ struct {
+ } xa_txn;
+ u_int32_t flags;
+};
+typedef enum { MU_REMOVE, MU_RENAME, MU_OPEN } mu_action;
+typedef struct __dbpginfo {
+ u_int8_t type;
+} PAGE;
+int __db_master_update(mdbp, sdbp, txn, subdb, type, action, newname, flags)
+ DB *mdbp, *sdbp;
+{
+ DB_ENV *dbenv;
+ DBC *dbc, *ndbc;
+ PAGE *p, *r;
+ int modify, ret, t_ret;
+ if ((ret = __db_cursor(mdbp, txn, &dbc,
+ (((dbenv)->flags & (0x0000002))
+ && modify) ? 35 : 0)) != 0)
+ goto err;
+ switch (action) {
+ case MU_REMOVE:
+ if ((ret = __memp_fget(mdbp->mpf, &sdbp->meta_pgno, 0, &p)) != 0)
+ goto err;
+ if ((((PAGE *)p)->type) == 9) {
+ if ((ret = __db_free(dbc, r)) != 0) { }
+ }
+ if ((ret = __db_free(dbc, p)) != 0) {
+ p = ((void *)0);
+ goto err;
+ }
+ p = ((void *)0);
+ }
+ err:
+ if (ndbc != ((void *)0) && (t_ret = __db_c_close(ndbc)) != 0 && ret == 0)
+ ret = t_ret;
+ return (ret);
+}
+
diff --git a/gcc/testsuite/gcc.dg/torture/pr24626-3.c b/gcc/testsuite/gcc.dg/torture/pr24626-3.c
new file mode 100644
index 000000000..778068268
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr24626-3.c
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+
+long fff(int*);
+
+long F2(int *node)
+{
+ long call_result = 0;
+
+ if (call_result = fff(node))
+ goto error_free_node;
+
+ T(node);
+ return 0;
+
+error_free_node:
+ T(node);
+ return call_result;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr24626-4.c b/gcc/testsuite/gcc.dg/torture/pr24626-4.c
new file mode 100644
index 000000000..a66801661
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr24626-4.c
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-options "-fmodulo-sched" } */
+
+int foo(short* vec1, short* vec2, short* vec3,int len )
+{
+ int temp,i;
+ for (i=0; i<len; i++) {
+ temp = vec1[i] * 2;
+ temp += vec2[i] * 3 ;
+ vec3[i] = temp;
+ }
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr24750-1.c b/gcc/testsuite/gcc.dg/torture/pr24750-1.c
new file mode 100644
index 000000000..58b1ea2ef
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr24750-1.c
@@ -0,0 +1,73 @@
+extern void free (void *);
+extern int unknown;
+extern int n0;
+extern short *s0;
+extern int n1;
+extern short *s1;
+extern short *s2;
+extern int *n2;
+extern int *n3;
+extern int n4;
+extern short *n5;
+extern int *n6;
+extern int n7;
+extern char *unc;
+
+void
+f (short *sp)
+{
+ int j = 0;
+ int i = 0;
+ int n8 = 0;
+ int n9 = 0;
+ short *s3 = sp;
+ short s4 = (short) unknown;
+ short s5 = (short) unknown;
+ char *c0 = unc;
+ int n10 = 0;
+ int n11 = 0;
+ int u0 = unknown;
+ int k = 0;
+
+ for (n8 = 1; n8 <= n7; n8++)
+ {
+ for (i = 1; i <= n0; i++)
+ c0[i] = 0;
+ for (i = 1; i <= u0; i++) { }
+ for (i = sp[0]; i != -32767; i = sp[i])
+ if (s4 == u0)
+ for (j = 1; j <= u0; j++)
+ if (!c0[s3[j]])
+ break;
+ }
+ for (n9 = 1; n9 <= n0; n9++) s1[unknown + n9] = n9;
+ for (i = 1; i <= n1; i++)
+ for (j = 1; j <= s4; j++)
+ s3[j] = s1[s3[j]];
+ for (n8 = 1; n8 <= n7; n8++)
+ for (i = 1; i <= s5; i++)
+ s3[i] = s1[s3[i]];
+ for (n9 = 1; n9 <= n0; n9++) sp[s1[n9]] = unknown;
+ for (n10 = 2; n10 < n4; n10++) { }
+ for (k = 1; k <= unknown; k++)
+ {
+ s4 = s0[n5[u0]];
+ for (i = 1; i <= s4; i++) { }
+ for (j = 1; j <= s4; j++)
+ if (n2[1] != 0)
+ if (i == unknown)
+ unknown = n3[unknown];
+ n6[u0] = n10;
+ }
+ for (k = n7; k >= n11; k--)
+ if (n2[k] == -32767)
+ break;
+ free (c0);
+
+ for (i = 1; i <= n7; i++)
+ {
+ for (j = 1; j <= s4; j++) { }
+ for (n8 = s2[unknown]; n8 != -32767; n8 = s2[n8]) { }
+ for (j = 1; j <= s5; j++) { }
+ }
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr24912-1.c b/gcc/testsuite/gcc.dg/torture/pr24912-1.c
new file mode 100644
index 000000000..947175f9d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr24912-1.c
@@ -0,0 +1,10 @@
+void foo(void);
+void
+bar (unsigned char *p)
+{
+ int j;
+ j = *(p) ;
+ j += ((signed char) (*p) ) << 8;
+ if (j)
+ foo();
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr25183.c b/gcc/testsuite/gcc.dg/torture/pr25183.c
new file mode 100644
index 000000000..0157b806c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr25183.c
@@ -0,0 +1,22 @@
+/* { dg-do compile } */
+/* { dg-options "-pedantic" } */
+
+enum err {
+ err_IO = 0x8a450000, /* { dg-warning "int" } */
+ err_NM,
+ err_EOF,
+ err_SE,
+ err_PT
+};
+static enum err E_;
+int error()
+{
+ switch (E_) {
+ case err_IO : break;
+ case err_NM : break;
+ case err_EOF : break;
+ case err_SE : break;
+ case err_PT : break;
+ default : return 0;
+ }
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr25481.c b/gcc/testsuite/gcc.dg/torture/pr25481.c
new file mode 100644
index 000000000..3072e5ecb
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr25481.c
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+
+struct s {
+ int *blah;
+};
+
+static struct s array[] = {
+ { 0 }
+};
+
+void
+foo (struct s *p)
+{
+ unsigned int n = 1;
+ struct s *q = &array[n];
+ while (p < q)
+ p++;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr25654.c b/gcc/testsuite/gcc.dg/torture/pr25654.c
new file mode 100644
index 000000000..03761e93c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr25654.c
@@ -0,0 +1,37 @@
+/* { dg-do run } */
+
+extern void abort (void) __attribute__((noreturn));
+
+union setconflict
+{
+ short a[20];
+ int b[10];
+};
+
+int
+main ()
+{
+ int sum = 0;
+ {
+ union setconflict a;
+ short *c;
+ c = a.a;
+ asm ("": "=r" (c):"0" (c));
+ *c = 0;
+ asm ("": "=r" (c):"0" (c));
+ sum += *c;
+ }
+ {
+ union setconflict a;
+ int *c;
+ c = a.b;
+ asm ("": "=r" (c):"0" (c));
+ *c = 1;
+ asm ("": "=r" (c):"0" (c));
+ sum += *c;
+ }
+
+ if (sum != 1)
+ abort();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr25706-1.c b/gcc/testsuite/gcc.dg/torture/pr25706-1.c
new file mode 100644
index 000000000..49bb32722
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr25706-1.c
@@ -0,0 +1,35 @@
+/* { dg-do assemble } */
+/* Invalid assembly generated due to port bug. */
+struct tcp_opt {
+ unsigned int window_clamp;
+ unsigned int rcv_ssthresh;
+ unsigned short advmss;
+};
+extern int sysctl_tcp_app_win;
+void tcp_init_buffer_space(struct tcp_opt *tp, int maxwin)
+{
+ if (tp->window_clamp >= maxwin)
+ if (sysctl_tcp_app_win && maxwin>4*tp->advmss)
+ tp->window_clamp
+ = ({
+ int _x = maxwin;
+ typeof(4*tp->advmss) _y = (4*tp->advmss);
+ _x > _y ? _x : _y;
+ });
+
+ if (sysctl_tcp_app_win
+ && tp->window_clamp > 2*tp->advmss
+ && tp->window_clamp + tp->advmss > maxwin)
+ tp->window_clamp
+ = ({
+ unsigned short _x = maxwin;
+ unsigned short _y = (maxwin-tp->advmss);
+ _x > _y ? _x : _y;
+ });
+ tp->rcv_ssthresh
+ = ({
+ unsigned int _x = (tp->rcv_ssthresh);
+ unsigned int _y = (tp->window_clamp);
+ _x < _y ? _x : _y;
+ });
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr25718-1.c b/gcc/testsuite/gcc.dg/torture/pr25718-1.c
new file mode 100644
index 000000000..8333a33a5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr25718-1.c
@@ -0,0 +1,27 @@
+/* { dg-do run } */
+/* PR 25718: invalid constant operand to the "bound" insn; error at
+ assembly time. We'll make sure the code is correct to: run a few
+ example values. */
+
+extern void exit (int);
+extern void abort (void);
+unsigned __attribute__ ((__noinline__)) foo(unsigned a)
+{
+ unsigned l;
+ l = (a >= (~0u - 512) ? (~0u - 512) : a);
+ return l;
+}
+
+int
+main (void)
+{
+ if (foo ((unsigned) -512) != (unsigned) -513
+ || foo ((unsigned) -514) != (unsigned) -514
+ || foo ((unsigned) -513) != (unsigned) -513
+ || foo ((unsigned) -1) != (unsigned) -513
+ || foo (513) != 513
+ || foo (0) != 0)
+ abort ();
+
+ exit (0);
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr25947-1.c b/gcc/testsuite/gcc.dg/torture/pr25947-1.c
new file mode 100644
index 000000000..8af6f8d46
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr25947-1.c
@@ -0,0 +1,22 @@
+/* PR target/25947: define_split in cris.md caused unrecognized insn. */
+/* { dg-options "-fpic" { target fpic } } */
+/* { dg-skip-if "requires unsupported run-time relocation" { spu-*-* } { "-O0" } { "" } } */
+
+extern char *rl_line_buffer;
+extern int rl_point;
+extern int rl_end;
+static const char *vi_motion = " hl^$0ftFT;,%wbeWBE|";
+void
+rl_vi_complete (int ignore, int key)
+{
+ if ((rl_point < rl_end)
+ &&
+ (!(((rl_line_buffer[rl_point]) == ' ')
+ || ((rl_line_buffer[rl_point]) == '\t'))))
+ {
+ if (!
+ (((rl_line_buffer[rl_point + 1]) == ' ')
+ || ((rl_line_buffer[rl_point + 1]) == '\t')))
+ rl_vi_end_word (1, 'E');
+ }
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr26222.c b/gcc/testsuite/gcc.dg/torture/pr26222.c
new file mode 100644
index 000000000..b580db673
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr26222.c
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+/* { dg-options "-fno-tree-pre -fno-tree-loop-im" } */
+
+void putShort (int, int);
+
+int t2;
+void f(int t1)
+{
+ int clutOffset = 52 + 256 * 3 * 2;
+ int x, y, z;
+ for (x = 0; x < 16; x++)
+ for (y = 0; y < 16; y++)
+ for (z = 0; z < 16; z++)
+ {
+ int offset = clutOffset + z * 6 + y * 16 * 6 + x * 16 * 16 * 6;
+ double xf = ((double) x) / ((double) 16 - 1.0);
+ double tt = xf;
+ putShort(offset, tt);
+ }
+}
+
diff --git a/gcc/testsuite/gcc.dg/torture/pr26258.c b/gcc/testsuite/gcc.dg/torture/pr26258.c
new file mode 100644
index 000000000..e9acd55cc
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr26258.c
@@ -0,0 +1,28 @@
+/* { dg-do run } */
+
+extern void abort(void);
+
+typedef struct Foo { int a; int b; } Foo;
+
+Foo foo(Foo first, Foo last, _Bool ret_first)
+{
+ Foo t;
+ Foo *t1 = (ret_first ? &first : &last);
+ first.a = 2;
+ last.b = 3;
+ t.a = t1->a;
+ t.b = t1->b;
+ t.a += first.a;
+ t.b += last.b;
+ return t;
+}
+
+int main()
+{
+ Foo first = (Foo){1, 2};
+ Foo last = (Foo){3, 4};
+ Foo ret = foo(first, last, 0);
+ if (ret.b != 6)
+ abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr26515.c b/gcc/testsuite/gcc.dg/torture/pr26515.c
new file mode 100644
index 000000000..a051e2e53
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr26515.c
@@ -0,0 +1,27 @@
+/* { dg-options "-march=v10" { target cris*-*-* } } */
+struct i
+{
+ long long i_size;
+ struct a *i_mapping;
+};
+struct p
+{
+ struct a *mapping;
+ long index;
+};
+extern void b (struct p*, unsigned);
+extern void u (struct p*);
+void
+block_page_mkwrite (struct i *i, struct p *p)
+{
+ unsigned end = 0;
+ long long size = 0;
+ size = i->i_size;
+ if ((p->mapping != i->i_mapping))
+ goto out_unlock;
+ if (((p->index + 1) << 13) > size)
+ end = size & ~(~(((1UL) << 13) - 1));
+ b (p, end);
+out_unlock:
+ u (p);
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr26565.c b/gcc/testsuite/gcc.dg/torture/pr26565.c
new file mode 100644
index 000000000..d45272df3
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr26565.c
@@ -0,0 +1,30 @@
+/* { dg-do run } */
+/* m32c is already packed. */
+/* { dg-skip-if "" { "m32c-*-*" } { "*" } { "" } } */
+
+void *memcpy(void *dest, const void *src, __SIZE_TYPE__ n);
+
+struct timeval {
+ long tv_sec;
+};
+
+struct outdata {
+ long align;
+ char seq;
+ struct timeval tv __attribute__((packed)); /* { dg-warning "attribute ignored" "" { target default_packed } } */
+};
+
+void send_probe(struct outdata *outdata, struct timeval *tp) __attribute__((noinline));
+void send_probe(struct outdata *outdata, struct timeval *tp)
+{
+ memcpy(&outdata->tv, tp, sizeof outdata->tv);
+}
+
+struct timeval t;
+struct outdata outdata;
+
+int main()
+{
+ send_probe(&outdata, &t);
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr26587.c b/gcc/testsuite/gcc.dg/torture/pr26587.c
new file mode 100644
index 000000000..ad5d60f3a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr26587.c
@@ -0,0 +1,29 @@
+/* { dg-do run } */
+/* { dg-require-effective-target int32plus } */
+
+extern void abort(void);
+typedef unsigned int BF_word;
+typedef BF_word BF_key[16 + 2];
+static struct {
+ BF_key P;
+} BF_current;
+int main(void)
+{
+ BF_word L;
+ BF_word tmp4, *ptr;
+ BF_word i;
+ for (i = 0; i < 16 + 2; i++)
+ BF_current.P[i] = i * 0x98765432;
+ L = 0;
+ ptr = BF_current.P;
+ do {
+ ptr += 2;
+ L ^= BF_current.P[0];
+ tmp4 = L >> 24;
+ L = tmp4 ^ BF_current.P[16 + 1];
+ *(ptr - 2) = L;
+ } while (ptr < &BF_current.P[16 + 2]);
+ if (L != 0x1fdb9752)
+ abort();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr26630.c b/gcc/testsuite/gcc.dg/torture/pr26630.c
new file mode 100644
index 000000000..96bab36a0
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr26630.c
@@ -0,0 +1,12 @@
+/* { dg-do run } */
+/* { dg-require-effective-target int32plus } */
+
+extern void abort(void);
+int main()
+{
+ int a1 = 40000;
+ int c1 = ( ((int)(short)(a1-10000)) + 10000)*2;
+ if (c1 != 80000)
+ abort();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr26672.c b/gcc/testsuite/gcc.dg/torture/pr26672.c
new file mode 100644
index 000000000..b13b5dcae
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr26672.c
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+
+int printf(const char *format, ...);
+extern const char help_string[];
+void app_opts(void) {
+ printf("%s", help_string);
+}
+const char help_string[] = "foo\n";
diff --git a/gcc/testsuite/gcc.dg/torture/pr26763-1.c b/gcc/testsuite/gcc.dg/torture/pr26763-1.c
new file mode 100644
index 000000000..37054e7a4
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr26763-1.c
@@ -0,0 +1,18 @@
+/* { dg-do run } */
+
+extern void abort(void);
+
+int try (int *a)
+{
+ return a + -1 > a;
+}
+
+int main(void)
+{
+ int bla[100];
+
+ if (try (bla + 50))
+ abort ();
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr26763-2.c b/gcc/testsuite/gcc.dg/torture/pr26763-2.c
new file mode 100644
index 000000000..d8155fb08
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr26763-2.c
@@ -0,0 +1,18 @@
+/* { dg-do run } */
+
+extern void abort(void);
+
+int try (char *a, int d)
+{
+ return a + d > a;
+}
+
+int main(void)
+{
+ char bla[100];
+
+ if (try (bla + 50, -1))
+ abort ();
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr26869.c b/gcc/testsuite/gcc.dg/torture/pr26869.c
new file mode 100644
index 000000000..6743319d1
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr26869.c
@@ -0,0 +1,7 @@
+/* { dg-do compile } */
+
+_Complex float f (_Complex float b, _Complex float c)
+{
+ _Complex float a = 1.0 + 0.0i;
+ return a / c;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr26898-1.c b/gcc/testsuite/gcc.dg/torture/pr26898-1.c
new file mode 100644
index 000000000..619412929
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr26898-1.c
@@ -0,0 +1,15 @@
+/* { dg-do link } */
+/* { dg-options "-fstrict-overflow" } */
+
+#include <limits.h>
+
+extern void link_error(void);
+int main()
+{
+ int i0, i1;
+ if (!(i0 + 1 < i1 + 1 == i0 < i1))
+ link_error ();
+ if (!(i0 + INT_MIN < i1 - INT_MAX == i0 < i1 - -1))
+ link_error ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr26898-2.c b/gcc/testsuite/gcc.dg/torture/pr26898-2.c
new file mode 100644
index 000000000..508fde4ce
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr26898-2.c
@@ -0,0 +1,12 @@
+/* { dg-do run } */
+
+#include <limits.h>
+
+int a = 0, b = INT_MAX - 1;
+extern void abort(void);
+int main()
+{
+ if (a - 1 > b + 1)
+ abort();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr26998.c b/gcc/testsuite/gcc.dg/torture/pr26998.c
new file mode 100644
index 000000000..d50c34473
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr26998.c
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+
+int decCompareOp (int result)
+{
+ if (result != (int)0x80000000)
+ {
+ result = -result;
+ return (result > 0);
+ }
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr27116-2.c b/gcc/testsuite/gcc.dg/torture/pr27116-2.c
new file mode 100644
index 000000000..9c748b245
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr27116-2.c
@@ -0,0 +1,13 @@
+/* { dg-do run } */
+
+extern void abort(void);
+
+int main (void)
+{
+ volatile long int n;
+ n = -2;
+
+ if ((-2147483647L - 1L) / (-n) != -1073741824L)
+ abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr27116.c b/gcc/testsuite/gcc.dg/torture/pr27116.c
new file mode 100644
index 000000000..70eeb1a86
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr27116.c
@@ -0,0 +1,15 @@
+/* { dg-do run } */
+
+extern void abort(void);
+
+int f(int a, int b)
+{
+ return (-1 - a) / (-b);
+}
+
+int main()
+{
+ if (f(__INT_MAX__, 2) != __INT_MAX__/2 + 1)
+ abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr27136.c b/gcc/testsuite/gcc.dg/torture/pr27136.c
new file mode 100644
index 000000000..32b7bf123
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr27136.c
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options "-ffast-math" } */
+
+void foo()
+{
+ double x;
+
+ for (x = 2; x < 10; x *= x)
+ ;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr27184.c b/gcc/testsuite/gcc.dg/torture/pr27184.c
new file mode 100644
index 000000000..cfb6ed2a8
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr27184.c
@@ -0,0 +1,22 @@
+/* Copyright 2006 Free Software Foundation */
+
+/* Make sure a and a1 alias each other.
+ Incomplete array types used to not be unified, which broke aliasing. */
+
+/* { dg-do run } */
+
+typedef long atype[];
+typedef long atype1[];
+int NumSift (atype *a, atype1 *a1)
+{
+ (*a)[0] = 0;
+ (*a1)[0] = 1;
+ return (*a)[0];
+}
+int main(void)
+{
+ long a[2];
+ if (!NumSift(&a, &a))
+ __builtin_abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr27302-2.c b/gcc/testsuite/gcc.dg/torture/pr27302-2.c
new file mode 100644
index 000000000..5c201b3d2
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr27302-2.c
@@ -0,0 +1,52 @@
+/* { dg-do run } */
+/* { dg-options "-fstrict-overflow" } */
+
+extern void link_error (void);
+
+void test0 (int a, int b)
+{
+ if ((a < b) != (b > a))
+ link_error ();
+
+ if ((a - 1 < b) != (a <= b))
+ link_error ();
+ if ((a - 2 < b) != (a - 1 <= b))
+ link_error ();
+ if ((a + -1 < b) != (a <= b))
+ link_error ();
+ if ((a + -2 < b) != (a + -1 <= b))
+ link_error ();
+
+ if ((a + 1 > b) != (a >= b))
+ link_error ();
+ if ((a + 2 > b) != (a + 1 >= b))
+ link_error ();
+ if ((a - -1 > b) != (a >= b))
+ link_error ();
+ if ((a - -2 > b) != (a - -1 >= b))
+ link_error ();
+
+ if ((a + 1 <= b) != (a < b))
+ link_error ();
+ if ((a + 2 <= b) != (a + 1 < b))
+ link_error ();
+ if ((a - -1 <= b) != (a < b))
+ link_error ();
+ if ((a - -2 <= b) != (a - -1 < b))
+ link_error ();
+
+ if ((a - 1 >= b) != (a > b))
+ link_error ();
+ if ((a - 2 >= b) != (a - 1 > b))
+ link_error ();
+ if ((a + -1 >= b) != (a > b))
+ link_error ();
+ if ((a + -2 >= b) != (a + -1 > b))
+ link_error ();
+}
+
+int main()
+{
+ test0 (1, 2);
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr27302.c b/gcc/testsuite/gcc.dg/torture/pr27302.c
new file mode 100644
index 000000000..0e41fc385
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr27302.c
@@ -0,0 +1,15 @@
+/* { dg-do run } */
+
+extern void link_error (void);
+
+void test0 (int a, int b)
+{
+ if ((a < b) != (b > a))
+ link_error ();
+}
+
+int main()
+{
+ test0 (1, 2);
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr27409.c b/gcc/testsuite/gcc.dg/torture/pr27409.c
new file mode 100644
index 000000000..430e6c8cc
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr27409.c
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+
+typedef struct {
+ struct { } z;
+} thang_t;
+
+struct {
+ short e;
+ thang_t f;
+ int g;
+} my_struct;
+
+void function(int blaz)
+{
+ thang_t *fp = &my_struct.f;
+ foo(fp);
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr27603.c b/gcc/testsuite/gcc.dg/torture/pr27603.c
new file mode 100644
index 000000000..8cb0235ab
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr27603.c
@@ -0,0 +1,16 @@
+/* { dg-do run } */
+
+void exit (int);
+void abort (void);
+int a;
+int main()
+{
+ int j;
+ for (j = 0; j < 6; j++)
+ {
+ if ((unsigned)j - 3 <= 1)
+ exit (0);
+ a = 1000 * (6 - j);
+ }
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr27743.c b/gcc/testsuite/gcc.dg/torture/pr27743.c
new file mode 100644
index 000000000..47d70457c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr27743.c
@@ -0,0 +1,16 @@
+/* { dg-do run { target { stdint_types } } } */
+
+#include <stdint.h>
+extern void abort(void);
+
+int32_t bar (int32_t a)
+{
+ return ((uint32_t) ((a) >> 2)) >> 15;
+}
+
+int main()
+{
+ if (bar (0xffff3000) != 0x1ffff)
+ abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr27773.c b/gcc/testsuite/gcc.dg/torture/pr27773.c
new file mode 100644
index 000000000..e30e540ff
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr27773.c
@@ -0,0 +1,6 @@
+/* { dg-do compile } */
+
+_Complex float f(_Complex float a, float b)
+{
+ return a - a*b;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr28045.c b/gcc/testsuite/gcc.dg/torture/pr28045.c
new file mode 100644
index 000000000..f2d16646c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr28045.c
@@ -0,0 +1,22 @@
+/* { dg-do run } */
+
+extern void abort(void);
+struct a
+{
+ unsigned int bits : 1;
+ signed long val : ((sizeof(long) * 8) - 1);
+};
+int Fnegate (struct a b)
+{
+ if ((-((long)b.val)) <= ((long) ((1UL << ((sizeof(long) * 8) - 2)) -1UL))
+ && (-((long)b.val)) >= (-(((long) ((1UL << ((sizeof(long) * 8) - 2)) -1UL))) - 1))
+ return 0 ;
+ abort ();
+}
+int main ()
+{
+ struct a b = {1, 1};
+ Fnegate (b);
+ return 0;
+}
+
diff --git a/gcc/testsuite/gcc.dg/torture/pr28230.c b/gcc/testsuite/gcc.dg/torture/pr28230.c
new file mode 100644
index 000000000..5ecc0c716
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr28230.c
@@ -0,0 +1,20 @@
+/* { dg-do run } */
+/* { dg-options "-fwrapv" } */
+
+void foo( unsigned long long bb, unsigned short tn, unsigned e, unsigned* w );
+void foo( unsigned long long bb, unsigned short tn, unsigned e, unsigned* w )
+{
+ unsigned n = tn + bb;
+ do {
+ e = (e > n) ? e : *w;
+ n -= (e > n) ? n : e;
+ if (*w)
+ *w = 0;
+ } while ( n );
+}
+int main()
+{
+ unsigned w = 0;
+ foo( 0, 0, 0, &w );
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr28268.c b/gcc/testsuite/gcc.dg/torture/pr28268.c
new file mode 100644
index 000000000..f143c0804
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr28268.c
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+
+int __attribute__((vector_size(8))) a;
+
+void foo()
+{
+ a += a*a;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr28814.c b/gcc/testsuite/gcc.dg/torture/pr28814.c
new file mode 100644
index 000000000..cc3c9f6ce
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr28814.c
@@ -0,0 +1,17 @@
+/* { dg-do compile { target { ilp32 || lp64 } } } */
+
+struct w49
+{
+ union
+ {
+ }
+ value;
+};
+f9887 (struct w49 a23040)
+{
+ unsigned long r9887;
+ if (((struct structure_type24753 *) (r9887 - 1)) == ((void *) 0))
+ {
+ backtrace ("stalin.sc", 7222, 248274);
+ }
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr28900.c b/gcc/testsuite/gcc.dg/torture/pr28900.c
new file mode 100644
index 000000000..75555f46e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr28900.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-ftree-vectorize" } */
+
+int synths_ ( float * rc)
+{
+ float r1, r2;
+ int i;
+ for (i = 0; i < 128; ++i)
+ {
+ r2 = rc[i];
+ r1 = ((r2) <= (.99f) ? (r2) : (.99f));
+ rc[i] = ((r1) >= (-.99f) ? (r1) : (-.99f));
+ }
+}
+
diff --git a/gcc/testsuite/gcc.dg/torture/pr29119.c b/gcc/testsuite/gcc.dg/torture/pr29119.c
new file mode 100644
index 000000000..63e5d8693
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr29119.c
@@ -0,0 +1,7 @@
+/* { dg-do compile } */
+
+void ldt_add_entry(void)
+{
+ __asm__ ("" :: "m"(({unsigned __v; __v;})));
+}
+
diff --git a/gcc/testsuite/gcc.dg/torture/pr29446.c b/gcc/testsuite/gcc.dg/torture/pr29446.c
new file mode 100644
index 000000000..5571c71e8
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr29446.c
@@ -0,0 +1,32 @@
+/* { dg-do compile } */
+
+void f(_Bool D917, int j0, int ubound1, int ubound5)
+{
+ int i, j = j0;
+ int (*abc)[3];
+ i = 1;
+ while (1)
+ {
+ if (j <= 3)
+ while (1)
+ {
+ if (i != j)
+ {
+ if (ubound1 <= 0)
+ return;
+ (*abc)[1] = 0;
+ }
+ else
+ {
+ if (j > ubound1)
+ return;
+ if (ubound5 <= 0)
+ return;
+ }
+ j = j + 1;
+ if (D917)
+ break;
+ }
+ i = i + 1;
+ }
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr29584.c b/gcc/testsuite/gcc.dg/torture/pr29584.c
new file mode 100644
index 000000000..4cb51d275
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr29584.c
@@ -0,0 +1,28 @@
+/* PR middle-end/29584 */
+/* { dg-do compile { target { ilp32 || lp64 } } } */
+
+extern void *foo1 (void);
+extern void foo2 (void);
+extern void foo3 (void *, void *);
+extern int foo4 (void);
+
+void
+bar (void)
+{
+ int i;
+ void *s;
+ for (i = 1; i < 4; i++)
+ {
+ if (foo4 ())
+ foo2 ();
+ switch (0x8000000UL + i * 0x400)
+ {
+ case 0x80000000UL ... 0x80000000UL + 0x3a000000UL - 1:
+ s = 0;
+ break;
+ default:
+ s = foo1 ();
+ }
+ foo3 ((void *) (0x8000000UL + i * 0x400), s);
+ }
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr30313.c b/gcc/testsuite/gcc.dg/torture/pr30313.c
new file mode 100644
index 000000000..aefeb7866
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr30313.c
@@ -0,0 +1,23 @@
+/* { dg-do compile } */
+
+static inline void bar(){}
+
+struct S
+{
+#if __INT_MAX__ == 32767
+ signed int i: 16;
+#elif __INT_MAX__ == 2147483647
+ signed int i: 32;
+#elif __INT_MAX__ == 9223372036854775807
+ signed int i: 64;
+#else
+#error Please add support for your target here
+#endif
+};
+
+int main()
+{
+ struct S x = {32};
+ sizeof(x.i+0);
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr30364-1.c b/gcc/testsuite/gcc.dg/torture/pr30364-1.c
new file mode 100644
index 000000000..64ee7e44e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr30364-1.c
@@ -0,0 +1,20 @@
+/* { dg-do run } */
+
+#include <limits.h>
+extern void abort (void);
+
+int f(int a, int b)
+{
+ if (a > INT_MAX - 15) return 0;
+ if (b > INT_MAX - 15) return 0;
+
+ int c = (a - 20) + (b - 20);
+ return c > INT_MAX - 15;
+}
+
+int main()
+{
+ if (f (INT_MAX - 15, 41) != 1)
+ abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr30364-2.c b/gcc/testsuite/gcc.dg/torture/pr30364-2.c
new file mode 100644
index 000000000..d8b678d53
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr30364-2.c
@@ -0,0 +1,20 @@
+/* { dg-do run } */
+
+#include <limits.h>
+extern void abort (void);
+
+int f(unsigned int a, unsigned int b)
+{
+ if (a > INT_MAX - 15) return 0;
+ if (b > INT_MAX - 15) return 0;
+
+ int c = (a - 20) + (b - 20);
+ return c > INT_MAX - 15;
+}
+
+int main()
+{
+ if (f (INT_MAX - 15, 41) != 1)
+ abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr30364-3.c b/gcc/testsuite/gcc.dg/torture/pr30364-3.c
new file mode 100644
index 000000000..ae96ba39f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr30364-3.c
@@ -0,0 +1,21 @@
+/* { dg-do run } */
+/* { dg-options "-fwrapv" } */
+
+#include <limits.h>
+extern void abort (void);
+
+int f(int a, int b)
+{
+ if (a > INT_MAX - 15) return 0;
+ if (b > INT_MAX - 15) return 0;
+
+ int c = (a - 20) + (b - 20);
+ return c > INT_MAX - 15;
+}
+
+int main()
+{
+ if (f (INT_MAX - 15, 41) != 1)
+ abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr30375.c b/gcc/testsuite/gcc.dg/torture/pr30375.c
new file mode 100644
index 000000000..435c38f13
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr30375.c
@@ -0,0 +1,37 @@
+/* { dg-do run } */
+
+typedef struct _s {
+ int a;
+ int b;
+ int c;
+ int d;
+} s;
+
+extern void abort(void);
+
+void __attribute__((noinline)) g(s *p)
+{
+ if (p->d != 0)
+ abort ();
+}
+
+char *c = (void*)0;
+void __attribute__((noinline)) f(void) { if (c) *c = 1; }
+
+void test_signed_msg_encoding(void)
+{
+ s signInfo = { sizeof(signInfo), 0 };
+
+ signInfo.b = 1;
+ signInfo.c = 0;
+ g(&signInfo);
+ signInfo.d = 1;
+ f();
+}
+
+int main()
+{
+ test_signed_msg_encoding ();
+ test_signed_msg_encoding ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr30665-1.c b/gcc/testsuite/gcc.dg/torture/pr30665-1.c
new file mode 100644
index 000000000..4650408d5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr30665-1.c
@@ -0,0 +1,24 @@
+/* PR target/30665: bug in cris.md peephole2 condition.
+ Testcase for trunk. */
+/* { dg-do run } */
+
+extern void abort (void);
+extern void exit (int);
+
+int __attribute__ ((__noinline__)) f (unsigned *p, int *x)
+{
+ int y = *p++ & 0xfff;
+ *x++ = y;
+ *x = *p;
+ return y;
+}
+
+int main (void)
+{
+ unsigned u[2] = { 0x3aad, 0x5ad1 };
+ int x[2] = {17689, 23456};
+
+ if (f (u, x) != 0xaad || x[0] != 0xaad || x[1] != 0x5ad1)
+ abort ();
+ exit (0);
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr30665-2.c b/gcc/testsuite/gcc.dg/torture/pr30665-2.c
new file mode 100644
index 000000000..a2cbf024c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr30665-2.c
@@ -0,0 +1,57 @@
+/* PR target/30665: bug in cris.md peephole2 condition.
+ Original reduced testcase (fails on 3.2.1 derivate, not on trunk). */
+/* { dg-do run } */
+
+extern void abort (void);
+extern void exit (int);
+
+struct t
+{
+ unsigned int a : 12;
+ unsigned int b : 12;
+ unsigned int dummy1 : 8;
+};
+
+struct area
+{
+ int xa;
+ int xb;
+};
+
+struct c
+{
+ struct area ii;
+};
+
+static struct c c;
+
+void __attribute__ ((__noinline__)) g(int a)
+{
+ if (a != 79)
+ abort ();
+}
+
+void __attribute__ ((__noinline__)) h(struct t tt)
+{
+ if (tt.a != 20 || tt.b != 79)
+ abort ();
+}
+
+void __attribute__ ((__noinline__)) s(void);
+
+int main(int argc, char **argv)
+{
+ c.ii.xa = 20;
+ c.ii.xb = 79;
+
+ s();
+
+ exit (0);
+}
+
+void __attribute__ ((__noinline__)) s(void)
+{
+ struct t ii_x = { .a = c.ii.xa, .b = c.ii.xb };
+ g(c.ii.xb);
+ h(ii_x);
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr31115.c b/gcc/testsuite/gcc.dg/torture/pr31115.c
new file mode 100644
index 000000000..1395a34b3
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr31115.c
@@ -0,0 +1,22 @@
+/* { dg-do run } */
+
+extern void exit(int);
+extern void abort();
+void foo (int e1)
+{
+ if (e1 < 0)
+ {
+ e1 = -e1;
+ if (e1 >>= 4)
+ {
+ if (e1 >= 1 << 5)
+ exit(0);
+ }
+ }
+}
+
+int main()
+{
+ foo(-(1<<9));
+ abort();
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr31254.c b/gcc/testsuite/gcc.dg/torture/pr31254.c
new file mode 100644
index 000000000..cec301273
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr31254.c
@@ -0,0 +1,26 @@
+/* { dg-do compile } */
+
+struct timespec
+{
+ long tv_sec;
+ long tv_nsec;
+};
+struct inode
+{
+ struct timespec i_atime;
+ struct timespec i_mtime;
+};
+struct afs_vnode
+{
+ struct inode vfs_inode;
+};
+static inline
+ struct inode *AFS_VNODE_TO_I (struct afs_vnode *vnode)
+{
+ return &vnode->vfs_inode;
+};
+afs_inode_map_status (struct afs_vnode *vnode)
+{
+ struct inode *inode = AFS_VNODE_TO_I (vnode);
+ inode->i_atime = inode->i_mtime;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr32897.c b/gcc/testsuite/gcc.dg/torture/pr32897.c
new file mode 100644
index 000000000..3dc43ece0
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr32897.c
@@ -0,0 +1,27 @@
+/* { dg-options "-G0" { target mips*-*-* } } */
+
+volatile int g[32];
+long long gll;
+double gd;
+
+#define MULTI(X) \
+ X( 1), X( 2), X( 3), X( 4), X( 5), X( 6), X( 7), X( 8), X( 9), X(10), \
+ X(11), X(12), X(13), X(14), X(15), X(16), X(17), X(18), X(19), X(20), \
+ X(21), X(22), X(23), X(24), X(25), X(26), X(27), X(28), X(29), X(30)
+
+#define DECLARE(INDEX) x##INDEX
+#define COPY_IN(INDEX) x##INDEX = g[INDEX]
+#define COPY_OUT(INDEX) g[INDEX] = x##INDEX
+
+void
+test (int n)
+{
+ union { long long l; double d; } u = { 0x12345678 };
+ gll = u.l;
+ int MULTI (DECLARE);
+ MULTI (COPY_IN);
+ MULTI (COPY_OUT);
+ MULTI (COPY_OUT);
+ MULTI (COPY_OUT);
+ gd = u.d;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr33560.c b/gcc/testsuite/gcc.dg/torture/pr33560.c
new file mode 100644
index 000000000..7eea1e3f6
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr33560.c
@@ -0,0 +1,29 @@
+/* { dg-do run } */
+
+struct T
+{
+ int a, b;
+} t;
+
+__attribute__((noinline)) struct T *f (struct T *p)
+{
+ struct T *q = __builtin_malloc (sizeof (struct T));
+ *q = *p;
+ return q;
+}
+
+int main (void)
+{
+ struct T *p;
+
+ t.a = 1;
+ t.b = 2;
+ p = f (&t);
+ t.a = 3;
+
+ if (p->a != 1)
+ __builtin_abort ();
+
+ return 0;
+}
+
diff --git a/gcc/testsuite/gcc.dg/torture/pr33563.c b/gcc/testsuite/gcc.dg/torture/pr33563.c
new file mode 100644
index 000000000..33e78521c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr33563.c
@@ -0,0 +1,21 @@
+/* { dg-do run } */
+
+struct T
+{
+ int a, b;
+} t, q;
+
+int main (void)
+{
+ struct T *p;
+
+ t.a = 1;
+ t.b = 2;
+ q = t;
+ t.a = 3;
+
+ if (q.a != 1)
+ __builtin_abort ();
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr33655.c b/gcc/testsuite/gcc.dg/torture/pr33655.c
new file mode 100644
index 000000000..2f9da65ae
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr33655.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+typedef struct {
+ unsigned long attr;
+ int chars[2];
+} cchar_t;
+typedef struct _win_st {
+ cchar_t _bkgrnd;
+} WINDOW;
+void render_char(WINDOW *win, cchar_t ch)
+{
+ if ((ch).chars[0] == L' '
+ && (ch).chars[1] == L'\0')
+ win->_bkgrnd = ch;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr33848.c b/gcc/testsuite/gcc.dg/torture/pr33848.c
new file mode 100644
index 000000000..c3b85e9e5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr33848.c
@@ -0,0 +1,43 @@
+/* &&foo should be hoisted, but on most targets, excess register pressure
+ forces it to be rematerialized before "data != &&foo". On targets that
+ have a "branch if registers are equal" instruction, this leads to the
+ branch having two LABEL_REFs: one for the branch target and one for
+ &&foo. When reloading &&foo into a register, reload would wrongly
+ say that &&foo was the target of the branch, and the real target would
+ then be removed as dead. */
+/* { dg-do link } */
+#define NVARS 30
+#define MULTI(X) \
+ X( 0), X( 1), X( 2), X( 3), X( 4), X( 5), X( 6), X( 7), X( 8), X( 9), \
+ X(10), X(11), X(12), X(13), X(14), X(15), X(16), X(17), X(18), X(19), \
+ X(20), X(21), X(22), X(23), X(24), X(25), X(26), X(27), X(28), X(29)
+
+#define DECLARE(INDEX) i##INDEX = gv[INDEX]
+#define COPY(INDEX) gv[INDEX] = i##INDEX
+
+volatile int gv[NVARS];
+void *volatile data;
+
+int
+main (void)
+{
+ __label__ foo;
+
+ if (gv[0] == 1)
+ goto foo;
+ data = &&foo;
+ do
+ {
+ int MULTI (DECLARE);
+ MULTI (COPY);
+ MULTI (COPY);
+ MULTI (COPY);
+ if (data != &&foo)
+ gv[0] = 1;
+ else
+ gv[1] = 2;
+ }
+ while (gv[0] > 0);
+ foo:
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr33870.c b/gcc/testsuite/gcc.dg/torture/pr33870.c
new file mode 100644
index 000000000..9c0e30d94
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr33870.c
@@ -0,0 +1,29 @@
+/* { dg-do run } */
+
+struct X {
+ int i;
+ int a[4];
+} m;
+
+int a[4];
+
+int __attribute__((noinline)) foo(int b)
+{
+ int (*p)[4] = b ? &a : &m.a;
+ a[3] = 0;
+ (*p)[3] = 1;
+ return (*p)[3] + (*p)[2] + (*p)[1] + a[0] + a[3];
+}
+
+extern void abort (void);
+
+int main()
+{
+ int i;
+ for (i = 0; i < 4; ++i)
+ a[i] = 0;
+ if (foo(1) != 2)
+ abort ();
+ return 0;
+}
+
diff --git a/gcc/testsuite/gcc.dg/torture/pr34174-1.c b/gcc/testsuite/gcc.dg/torture/pr34174-1.c
new file mode 100644
index 000000000..0f1ed067f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr34174-1.c
@@ -0,0 +1,44 @@
+/* { dg-do run } */
+/* Based on PR target/27386 testcase by Joerg Wunsch. */
+
+extern void abort (void);
+extern void exit (int);
+
+#if __INT_MAX__ >= 9223372036854775807LL
+typedef unsigned int uint64_t;
+#elif __LONG_MAX__ >= 9223372036854775807LL
+typedef unsigned long int uint64_t;
+#elif __LONG_LONG_MAX__ >= 9223372036854775807LL
+typedef unsigned long long int uint64_t;
+#else
+int
+main (void)
+{
+ exit (0);
+}
+#endif
+
+uint64_t a, b, c;
+
+int
+foo (uint64_t x, uint64_t y, uint64_t z, int i)
+{
+ a = x;
+ b = y;
+ c = z;
+ return 2 * i;
+}
+
+int
+main (void)
+{
+ if (foo (1234512345123ull, 3456734567345ull, 7897897897897ull, 42) != 84)
+ abort ();
+ if (a != 1234512345123ull)
+ abort ();
+ if (b != 3456734567345ull)
+ abort ();
+ if (c != 7897897897897ull)
+ abort ();
+ exit (0);
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr34330.c b/gcc/testsuite/gcc.dg/torture/pr34330.c
new file mode 100644
index 000000000..0ed2f9fb3
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr34330.c
@@ -0,0 +1,22 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target pthread } */
+/* { dg-options "-ftree-parallelize-loops=4 -ftree-vectorize" } */
+
+struct T
+{
+ int t;
+ struct { short s1, s2, s3, s4; } *s;
+};
+
+void
+foo (int *a, int *b, int *c, int *d, struct T *e)
+{
+ int i;
+ for (i = 0; i < e->t; i++)
+ {
+ e->s[i].s1 = a[i];
+ e->s[i].s2 = b[i];
+ e->s[i].s3 = c[i];
+ e->s[i].s4 = d[i];
+ }
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr35227.c b/gcc/testsuite/gcc.dg/torture/pr35227.c
new file mode 100644
index 000000000..d951d250f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr35227.c
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+
+mandel(double _Complex C)
+{
+ int py;
+ C = (__extension__ 1.0iF) * (double)py;
+ return cabs(C); /* { dg-warning "incompatible" } */
+}
+
diff --git a/gcc/testsuite/gcc.dg/torture/pr35400.c b/gcc/testsuite/gcc.dg/torture/pr35400.c
new file mode 100644
index 000000000..285dc72e3
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr35400.c
@@ -0,0 +1,22 @@
+/* { dg-do compile } */
+/* { dg-options "-Wtype-limits" } */
+
+struct A
+{
+ struct A *p;
+};
+
+int foo(const struct A *q)
+{
+ return q->p == q;
+}
+
+void bar(int);
+
+void baz()
+{
+ struct A a;
+
+ while (foo(&a))
+ bar(foo(&a));
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr35771-1.c b/gcc/testsuite/gcc.dg/torture/pr35771-1.c
new file mode 100644
index 000000000..b3fd554da
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr35771-1.c
@@ -0,0 +1,9 @@
+/* { dg-do run { target i?86-*-* x86_64-*-* } } */
+/* { dg-options "-msse2" } */
+/* { dg-require-effective-target sse2_runtime } */
+
+typedef float __m128 __attribute__ ((__vector_size__ (16), __may_alias__));
+
+#define TYPE __m128
+
+#include "pr35771.h"
diff --git a/gcc/testsuite/gcc.dg/torture/pr35771-2.c b/gcc/testsuite/gcc.dg/torture/pr35771-2.c
new file mode 100644
index 000000000..a033caefd
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr35771-2.c
@@ -0,0 +1,9 @@
+/* { dg-do run { target i?86-*-* x86_64-*-* } } */
+/* { dg-options "-msse2" } */
+/* { dg-require-effective-target sse2_runtime } */
+
+typedef double __m128d __attribute__ ((__vector_size__ (16), __may_alias__));
+
+#define TYPE __m128d
+
+#include "pr35771.h"
diff --git a/gcc/testsuite/gcc.dg/torture/pr35771-3.c b/gcc/testsuite/gcc.dg/torture/pr35771-3.c
new file mode 100644
index 000000000..fcbe86cb1
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr35771-3.c
@@ -0,0 +1,9 @@
+/* { dg-do run { target i?86-*-* x86_64-*-* } } */
+/* { dg-options "-msse2" } */
+/* { dg-require-effective-target sse2_runtime } */
+
+typedef long long __m128i __attribute__ ((__vector_size__ (16), __may_alias__));
+
+#define TYPE __m128i
+
+#include "pr35771.h"
diff --git a/gcc/testsuite/gcc.dg/torture/pr35771.h b/gcc/testsuite/gcc.dg/torture/pr35771.h
new file mode 100644
index 000000000..7b921c41b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr35771.h
@@ -0,0 +1,30 @@
+typedef TYPE __attribute__((aligned(1))) unaligned;
+
+extern void abort (void);
+
+
+TYPE __attribute__((noinline))
+foo (TYPE a1, TYPE a2, TYPE a3, TYPE a4,
+ TYPE a5, TYPE a6, TYPE a7, TYPE a8,
+ int b1, int b2, int b3, int b4, int b5, int b6, int b7, unaligned y)
+{
+ return y;
+}
+
+void
+do_test (void)
+{
+ unaligned x;
+ TYPE y = { 0 };
+ x = y;
+ y = foo (y, y, y, y, y, y, y, y, 1, 2, 3, 4, 5, 6, -1, x);
+ if (__builtin_memcmp (&y, &x, sizeof (y)) != 0)
+ abort ();
+}
+
+int
+main (void)
+{
+ do_test ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr35833.c b/gcc/testsuite/gcc.dg/torture/pr35833.c
new file mode 100644
index 000000000..2e740f29f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr35833.c
@@ -0,0 +1,22 @@
+/* { dg-do run } */
+/* { dg-options "-ftree-vrp" } */
+
+struct S {struct S *field;};
+struct S True, False, Z;
+static inline int f(void) {return 1;}
+static inline int g(struct S **obj) {
+ return f() && *obj == &Z;
+}
+struct S **h(struct S **x) {
+ if (x)
+ return g(x) ? &True.field : &False.field;
+ else
+ return &True.field;
+}
+extern void abort (void);
+int main()
+{
+ if (h(&False.field) != &False.field)
+ abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr35842.c b/gcc/testsuite/gcc.dg/torture/pr35842.c
new file mode 100644
index 000000000..05b26d84c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr35842.c
@@ -0,0 +1,12 @@
+/* { dg-do compile { target { *-*-mingw* } } } */
+extern __attribute__((dllimport)) const int SSL_ImplementedCiphers[];
+extern void SSL_GetCipherSuiteInfo(int cipherSuite);
+void nsCipherInfo(int SSL_NumImplementedCiphers)
+{
+ int i;
+ for (i = 0; i < SSL_NumImplementedCiphers; ++i)
+ {
+ const int i_id = SSL_ImplementedCiphers[i];
+ SSL_GetCipherSuiteInfo(i_id);
+ }
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr36066.c b/gcc/testsuite/gcc.dg/torture/pr36066.c
new file mode 100644
index 000000000..0e1d1ce30
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr36066.c
@@ -0,0 +1,54 @@
+/* { dg-do compile } */
+/* { dg-options "-funsafe-loop-optimizations -ftree-vrp" } */
+
+typedef int FLAC__int32;
+typedef int FLAC__bool;
+typedef struct { } FLAC__Subframe;
+typedef enum { FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT = 0, FLAC__CHANNEL_ASSIGNMENT_LEFT_SIDE = 1, FLAC__CHANNEL_ASSIGNMENT_RIGHT_SIDE = 2, FLAC__CHANNEL_ASSIGNMENT_MID_SIDE = 3 } FLAC__ChannelAssignment;
+typedef struct {
+ struct FLAC__StreamEncoderProtected *protected_;
+ struct FLAC__StreamEncoderPrivate *private_;
+} FLAC__StreamEncoder;
+typedef struct FLAC__StreamEncoderProtected {
+ FLAC__bool loose_mid_side_stereo;
+ unsigned channels;
+ unsigned blocksize;
+} FLAC__StreamEncoderProtected;
+typedef struct FLAC__StreamEncoderPrivate {
+ FLAC__int32 *integer_signal[(8u)];
+ FLAC__Subframe subframe_workspace_mid_side[2][2];
+ unsigned best_subframe_mid_side[2];
+ unsigned loose_mid_side_stereo_frame_count;
+} FLAC__StreamEncoderPrivate;
+static void get_wasted_bits_(FLAC__int32 signal[], unsigned samples)
+{
+ unsigned i;
+ FLAC__int32 x = 0;
+ for(i = 0; i < samples && !(x&1); i++)
+ x |= signal[i];
+}
+FLAC__Subframe * process_subframes_(FLAC__StreamEncoder *encoder, unsigned *bits)
+{
+ unsigned channel;
+ FLAC__Subframe *left_subframe = 0;
+ FLAC__ChannelAssignment channel_assignment;
+ for(channel = 0; channel < encoder->protected_->channels; channel++)
+ get_wasted_bits_(encoder->private_->integer_signal[channel], encoder->protected_->blocksize);
+ if(encoder->protected_->loose_mid_side_stereo && encoder->private_->loose_mid_side_stereo_frame_count > 0)
+ channel_assignment = FLAC__CHANNEL_ASSIGNMENT_MID_SIDE;
+ else {
+ FLAC__ChannelAssignment ca = (FLAC__ChannelAssignment)1;
+ unsigned min_bits = bits[0];
+ for(channel_assignment = (FLAC__ChannelAssignment)0; (int)ca <= 3; ca = (FLAC__ChannelAssignment)((int)ca + 1))
+ if(bits[ca] < min_bits)
+ channel_assignment = ca;
+ }
+ switch(channel_assignment) {
+ case FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT:
+ case FLAC__CHANNEL_ASSIGNMENT_LEFT_SIDE:
+ case FLAC__CHANNEL_ASSIGNMENT_RIGHT_SIDE:
+ case FLAC__CHANNEL_ASSIGNMENT_MID_SIDE:
+ left_subframe = &encoder->private_->subframe_workspace_mid_side[0][encoder->private_->best_subframe_mid_side[0]];
+ }
+ return left_subframe;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr36227.c b/gcc/testsuite/gcc.dg/torture/pr36227.c
new file mode 100644
index 000000000..462b2c4f0
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr36227.c
@@ -0,0 +1,17 @@
+/* { dg-do run { target { stdint_types } } } */
+
+#include <stdint.h>
+extern void abort (void);
+int main()
+{
+ int i = 1;
+ int *p = &i;
+ uintptr_t iptr;
+
+ iptr = (uintptr_t)p - (uintptr_t)&iptr;
+ p = (int *)((uintptr_t)&iptr + iptr);
+ if (*p != 1)
+ abort ();
+ return 0;
+}
+
diff --git a/gcc/testsuite/gcc.dg/torture/pr36244.c b/gcc/testsuite/gcc.dg/torture/pr36244.c
new file mode 100644
index 000000000..b1b14be18
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr36244.c
@@ -0,0 +1,40 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target pthread } */
+/* { dg-options "-O3 -ftree-parallelize-loops=4" } */
+
+struct p7prior_s {
+ int mnum; /* number of mat emission Dirichlet mixtures */
+ float mq[200]; /* probabilities of mnum components */
+ float m[200][20]; /* match emission terms per mix component */
+};
+
+struct p7prior_s *default_amino_prior(void);
+struct p7prior_s *P7AllocPrior(void);
+
+struct p7prior_s *
+default_amino_prior(void)
+{
+ struct p7prior_s *pri;
+ int x, q;
+
+ static float defmq[5] = {
+ 0.178091, 0.056591, 0.0960191, 0.0781233, 0.0834977 };
+ static float defm[5][6] = {
+ { 0.270671, 0.039848, 0.017576, 0.016415, 0.014268, 0.216147 },
+ { 0.021465, 0.010300, 0.011741, 0.010883, 0.385651, 0.029156 },
+ { 0.561459, 0.045448, 0.438366, 0.764167, 0.087364, 0.583402 },
+ { 0.070143, 0.011140, 0.019479, 0.094657, 0.013162, 0.073732 },
+ { 0.041103, 0.014794, 0.005610, 0.010216, 0.153602, 0.012049 }
+ };
+
+ pri = P7AllocPrior();
+ pri->mnum = 5;
+ for (q = 0; q < pri->mnum; q++)
+ {
+ pri->mq[q] = defmq[q];
+ for (x = 0; x < 6; x++)
+ pri->m[q][x] = defm[q][x];
+ }
+ return pri;
+}
+
diff --git a/gcc/testsuite/gcc.dg/torture/pr36373-1.c b/gcc/testsuite/gcc.dg/torture/pr36373-1.c
new file mode 100644
index 000000000..9cd02c57a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr36373-1.c
@@ -0,0 +1,35 @@
+/* { dg-do run } */
+/* { dg-options "-fno-tree-sra" } */
+
+extern void abort (void);
+struct Bar {
+ struct Foo {
+ int *p;
+ } x;
+ int *q;
+};
+struct Foo __attribute__((noinline))
+bar(int *p)
+{
+ struct Foo f;
+ f.p = p;
+ return f;
+}
+void __attribute__((noinline))
+foo(struct Foo f)
+{
+ *f.p = 0;
+}
+int main()
+{
+ int a, b;
+ a = 0;
+ b = 1;
+ struct Bar f;
+ f.x = bar (&b);
+ f.q = &a;
+ foo(f.x);
+ if (b != 0)
+ abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr36373-10.c b/gcc/testsuite/gcc.dg/torture/pr36373-10.c
new file mode 100644
index 000000000..ed7017728
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr36373-10.c
@@ -0,0 +1,29 @@
+/* { dg-do run } */
+
+#if (__SIZEOF_LONG_LONG__ == __SIZEOF_POINTER__)
+typedef unsigned long long uintptr_t;
+#elif (__SIZEOF_LONG__ == __SIZEOF_POINTER__)
+typedef unsigned long uintptr_t;
+#elif (__SIZEOF_INT__ == __SIZEOF_POINTER__)
+typedef unsigned int uintptr_t;
+#else
+#error Add target support here
+#endif
+
+void __attribute__((noinline))
+foo(uintptr_t l)
+{
+ int *p = (int *)l;
+ *p = 1;
+}
+
+extern void abort (void);
+int main()
+{
+ int b = 0;
+ uintptr_t l = (uintptr_t)&b;
+ foo(l);
+ if (b != 1)
+ abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr36373-2.c b/gcc/testsuite/gcc.dg/torture/pr36373-2.c
new file mode 100644
index 000000000..2653182a5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr36373-2.c
@@ -0,0 +1,37 @@
+/* { dg-do run } */
+/* { dg-options "-fno-tree-sra" } */
+
+extern void abort (void);
+struct Foo {
+ int *p;
+};
+struct Bar {
+ struct Foo *x;
+ int *q;
+};
+struct Foo __attribute__((noinline))
+bar(int *p)
+{
+ struct Foo f;
+ f.p = p;
+ return f;
+}
+void __attribute__((noinline))
+foo(struct Foo f)
+{
+ *f.p = 0;
+}
+int main()
+{
+ int a, b;
+ a = 0;
+ b = 1;
+ struct Bar f;
+ struct Foo g = bar (&b);
+ f.x = &g;
+ f.q = &a;
+ foo(*f.x);
+ if (b != 0)
+ abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr36373-3.c b/gcc/testsuite/gcc.dg/torture/pr36373-3.c
new file mode 100644
index 000000000..d5ad93e1b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr36373-3.c
@@ -0,0 +1,36 @@
+/* { dg-do run } */
+
+extern void abort (void);
+struct Foo {
+ int *p;
+};
+struct Bar {
+ struct Foo *x;
+ int *q;
+};
+struct Foo __attribute__((noinline))
+bar(int *p)
+{
+ struct Foo f;
+ f.p = p;
+ return f;
+}
+void __attribute__((noinline))
+foo(struct Foo f)
+{
+ *f.p = 0;
+}
+int main()
+{
+ int a, b;
+ a = 0;
+ b = 1;
+ struct Bar f;
+ struct Foo g = bar (&b);
+ f.x = &g;
+ f.q = &a;
+ foo(*f.x);
+ if (b != 0)
+ abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr36373-4.c b/gcc/testsuite/gcc.dg/torture/pr36373-4.c
new file mode 100644
index 000000000..5f3b83349
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr36373-4.c
@@ -0,0 +1,33 @@
+/* { dg-do run } */
+
+extern void abort (void);
+struct Foo {
+ int *p;
+ int *q;
+};
+struct Foo __attribute__((noinline))
+bar(int *p)
+{
+ struct Foo f;
+ f.p = p;
+ return f;
+}
+void __attribute__((noinline))
+foo(struct Foo f)
+{
+ *f.p = 0;
+}
+int main()
+{
+ int a, b;
+ a = 0;
+ b = 1;
+ struct Foo f;
+ f = bar (&b);
+ f.q = &a;
+ foo(f);
+ if (b != 0)
+ abort ();
+ return 0;
+}
+
diff --git a/gcc/testsuite/gcc.dg/torture/pr36373-5.c b/gcc/testsuite/gcc.dg/torture/pr36373-5.c
new file mode 100644
index 000000000..0061ef418
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr36373-5.c
@@ -0,0 +1,34 @@
+/* { dg-do run } */
+/* { dg-options "-fno-tree-sra" } */
+
+extern void abort (void);
+struct Foo {
+ int *p;
+ int *q;
+};
+struct Foo __attribute__((noinline))
+bar(int *p)
+{
+ struct Foo f;
+ f.p = p;
+ return f;
+}
+void __attribute__((noinline))
+foo(struct Foo f)
+{
+ *f.p = 0;
+}
+int main()
+{
+ int a, b;
+ a = 0;
+ b = 1;
+ struct Foo f;
+ f = bar (&b);
+ f.q = &a;
+ foo(f);
+ if (b != 0)
+ abort ();
+ return 0;
+}
+
diff --git a/gcc/testsuite/gcc.dg/torture/pr36373-6.c b/gcc/testsuite/gcc.dg/torture/pr36373-6.c
new file mode 100644
index 000000000..c55e3ff3f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr36373-6.c
@@ -0,0 +1,30 @@
+/* { dg-do run } */
+/* { dg-options "-fno-tree-sra" } */
+
+extern void abort (void);
+struct Foo {
+ int *p;
+} x;
+struct Foo __attribute__((noinline))
+bar(int *p)
+{
+ struct Foo f;
+ f.p = p;
+ return f;
+}
+void __attribute__((noinline))
+foo()
+{
+ *x.p = 0;
+}
+int main()
+{
+ int b;
+ b = 1;
+ struct Foo g = bar (&b);
+ x = g;
+ foo();
+ if (b != 0)
+ abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr36373-7.c b/gcc/testsuite/gcc.dg/torture/pr36373-7.c
new file mode 100644
index 000000000..103694e15
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr36373-7.c
@@ -0,0 +1,29 @@
+/* { dg-do run } */
+
+extern void abort (void);
+struct Foo {
+ int *p;
+} x;
+struct Foo __attribute__((noinline))
+bar(int *p)
+{
+ struct Foo f;
+ f.p = p;
+ return f;
+}
+void __attribute__((noinline))
+foo()
+{
+ *x.p = 0;
+}
+int main()
+{
+ int b;
+ b = 1;
+ struct Foo g = bar (&b);
+ x = g;
+ foo();
+ if (b != 0)
+ abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr36373-8.c b/gcc/testsuite/gcc.dg/torture/pr36373-8.c
new file mode 100644
index 000000000..9f77ea137
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr36373-8.c
@@ -0,0 +1,24 @@
+/* { dg-do run } */
+/* { dg-options "-fno-tree-sra" } */
+
+extern void abort (void);
+struct Foo {
+ int *p;
+} x;
+void __attribute__((noinline))
+foo()
+{
+ *x.p = 0;
+}
+int main()
+{
+ int b;
+ struct Foo g;
+ b = 1;
+ g.p = &b;
+ x = g;
+ foo();
+ if (b != 0)
+ abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr36373-9.c b/gcc/testsuite/gcc.dg/torture/pr36373-9.c
new file mode 100644
index 000000000..5588eadae
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr36373-9.c
@@ -0,0 +1,23 @@
+/* { dg-do run } */
+
+extern void abort (void);
+struct Foo {
+ int *p;
+} x;
+void __attribute__((noinline))
+foo()
+{
+ *x.p = 0;
+}
+int main()
+{
+ int b;
+ struct Foo g;
+ b = 1;
+ g.p = &b;
+ x = g;
+ foo();
+ if (b != 0)
+ abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr36400.c b/gcc/testsuite/gcc.dg/torture/pr36400.c
new file mode 100644
index 000000000..bd9f35a5f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr36400.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+struct barstruct { char const* some_string; };
+
+void changethepointer(struct barstruct***);
+
+void baz()
+{
+ struct barstruct bar1;
+ struct barstruct* barptr = &bar1;
+ struct barstruct** barptr2 = &barptr;
+ changethepointer(&barptr2);
+ barptr->some_string = "Everything OK";
+}
+
+/* { dg-final { scan-assembler "Everything OK" } } */
diff --git a/gcc/testsuite/gcc.dg/torture/pr36891.c b/gcc/testsuite/gcc.dg/torture/pr36891.c
new file mode 100644
index 000000000..53e6163de
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr36891.c
@@ -0,0 +1,22 @@
+/* { dg-do compile } */
+/* { dg-options "-ffast-math" } */
+/* { dg-options "-ffast-math -msse" { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */
+/* { dg-require-effective-target sse { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */
+
+#define __vector __attribute__((vector_size(16) ))
+__vector float f(void);
+void g(__vector float);
+void RRB( __vector float vdist, __vector float vx)
+{
+ int detail;
+ for(detail = 0; detail < 5;++detail)
+ {
+ __vector float frand = f();
+ __vector float pullperc = frand/ vdist;
+ __vector float pullx = vx * pullperc;
+ g(pullx);
+ }
+}
+
+/* Ignore a warning that is irrelevant to the purpose of this test. */
+/* { dg-prune-output ".*GCC vector returned by reference.*" } */
diff --git a/gcc/testsuite/gcc.dg/torture/pr36978.c b/gcc/testsuite/gcc.dg/torture/pr36978.c
new file mode 100644
index 000000000..cd1af4ebc
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr36978.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-funswitch-loops" } */
+
+unsigned short status;
+void foo (const _Bool flag)
+{
+ if (status == 2 || status == 7)
+ {
+ while (status != 2 && (status != 7 || !flag))
+ {
+ }
+ }
+}
+
diff --git a/gcc/testsuite/gcc.dg/torture/pr37731-1.c b/gcc/testsuite/gcc.dg/torture/pr37731-1.c
new file mode 100644
index 000000000..5c156b1f9
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr37731-1.c
@@ -0,0 +1,17 @@
+/* { dg-do run } */
+
+extern void abort ();
+
+unsigned long long xh = 1;
+
+int
+main ()
+{
+ unsigned long long yh = 0xffffffffull;
+ unsigned long long z = xh * yh;
+
+ if (z != yh)
+ abort ();
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr37731-2.c b/gcc/testsuite/gcc.dg/torture/pr37731-2.c
new file mode 100644
index 000000000..a7f8f1e02
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr37731-2.c
@@ -0,0 +1,17 @@
+/* { dg-do run } */
+
+extern void abort ();
+
+long long xh = 1;
+
+int
+main ()
+{
+ long long yh = 0xffffffffll;
+ long long z = xh * yh;
+
+ if (z != yh)
+ abort ();
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr37868.c b/gcc/testsuite/gcc.dg/torture/pr37868.c
new file mode 100644
index 000000000..1f89dff2f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr37868.c
@@ -0,0 +1,39 @@
+/* { dg-do run } */
+/* { dg-options "-fno-strict-aliasing" } */
+/* { dg-skip-if "unaligned access" { sparc*-*-* } "*" "" } */
+
+extern void abort (void);
+#if (__SIZEOF_INT__ <= 2)
+struct X {
+ unsigned char pad : 4;
+ unsigned int a : 16;
+ unsigned int b : 8;
+ unsigned int c : 6;
+} __attribute__((packed));
+#else
+struct X {
+ unsigned char pad : 4;
+ unsigned int a : 32;
+ unsigned int b : 24;
+ unsigned int c : 6;
+} __attribute__((packed));
+
+#endif
+
+
+int main (void)
+{
+ struct X x;
+ unsigned int bad_bits;
+
+ x.pad = -1;
+ x.a = -1;
+ x.b = -1;
+ x.c = -1;
+
+ bad_bits = ((unsigned int)-1) ^ *(1+(unsigned int *) &x);
+ if (bad_bits != 0)
+ abort ();
+ return 0;
+}
+
diff --git a/gcc/testsuite/gcc.dg/torture/pr37969.c b/gcc/testsuite/gcc.dg/torture/pr37969.c
new file mode 100644
index 000000000..cbb6f0598
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr37969.c
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+/* { dg-options "-funswitch-loops" } */
+
+void foo(double);
+void CreateDefaultTexture(double mnMinimum, double mnMaximum,
+ unsigned short nCreateWhat)
+{
+ double d = 0.0;
+ for(;;)
+ {
+ if(nCreateWhat & (0x0001)
+ && mnMinimum != 0.0)
+ d = mnMinimum;
+ if(nCreateWhat & (0x0002)
+ && mnMaximum != 0.0)
+ d = mnMaximum;
+ foo(d);
+ }
+}
+
diff --git a/gcc/testsuite/gcc.dg/torture/pr38271.c b/gcc/testsuite/gcc.dg/torture/pr38271.c
new file mode 100644
index 000000000..2c64a9b34
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr38271.c
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+/* { dg-options "-Wuninitialized" } */
+
+struct xxx {
+ short a;
+ short b;
+ void *c;
+};
+
+void bar(struct xxx);
+
+void foo(struct xxx *p, int i)
+{
+ struct xxx s0 = *p;
+ struct xxx s = s0;
+ if (s.a) i++;
+ bar(s);
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr38405.c b/gcc/testsuite/gcc.dg/torture/pr38405.c
new file mode 100644
index 000000000..3f93445cd
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr38405.c
@@ -0,0 +1,29 @@
+/* { dg-do run } */
+
+extern void abort ();
+extern int printf (char *__format, ...);
+
+struct vpiBinaryConst {
+ int signed_flag :1;
+ int sized_flag :1;
+};
+
+int binary_get(int code, struct vpiBinaryConst *rfp)
+{
+ switch (code) {
+ case 1:
+ return rfp->signed_flag ? 1 : 0;
+ default:
+ printf("error: %d not supported\n", code);
+ return code;
+ }
+}
+
+int main(void)
+{
+ struct vpiBinaryConst x={1,0};
+ int y=binary_get(1, &x);
+ if (y!=1)
+ abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr38774.c b/gcc/testsuite/gcc.dg/torture/pr38774.c
new file mode 100644
index 000000000..d6d7fcb0f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr38774.c
@@ -0,0 +1,16 @@
+/* PR rtl-optimization/38774 */
+/* { dg-do compile } */
+/* { dg-options "" } */
+/* { dg-options "-march=i686" { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */
+
+extern int bar (void);
+volatile int g;
+
+int
+foo (void)
+{
+ int a = 1 >= bar ();
+ if ((1 > 9223372036854775807LL - a && 1 - a ? : 1 + a) & 1)
+ return g;
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr38948.c b/gcc/testsuite/gcc.dg/torture/pr38948.c
new file mode 100644
index 000000000..98ed493cb
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr38948.c
@@ -0,0 +1,101 @@
+/* { dg-options "-fno-tree-sra" } */
+/* { dg-options "-fno-tree-sra -march=v32" { target cris-*-* } } */
+typedef unsigned char byte;
+typedef unsigned int uint;
+typedef int bool;
+typedef struct gs_const_string_s
+{
+ const byte *data;
+}
+gs_const_string;
+struct gs_matrix_s
+{
+ float xx, xy, yx, yy, tx, ty;
+};
+typedef struct gs_matrix_s gs_matrix;
+typedef long fixed;
+typedef struct gs_fixed_point_s
+{
+ fixed x, y;
+}
+gs_fixed_point;
+typedef struct gs_matrix_fixed_s
+{
+ int x;
+}
+gs_matrix_fixed;
+static int
+append_simple (const byte * glyph, const gs_matrix_fixed * pmat, void * ppath)
+{
+ int numContours =
+ (int) (((((uint) ((glyph)[0]) << 8) + (glyph)[1]) ^ 0x8000) - 0x8000);
+ const byte *pends = glyph + 10;
+ int code = 0;
+ {
+ uint i = 0;
+ uint np = 0;
+ gs_fixed_point pt = {0};
+ uint reps = 0;
+ for (i = 0, np = 0; i < numContours; ++i)
+ {
+ bool move = ((bool) 1);
+ uint last_point =
+ (((uint) ((pends + i * 2)[0]) << 8) + (pends + i * 2)[1]);
+ int off_curve = 0;
+ gs_fixed_point cpoints[3];
+ for (; np <= last_point; --reps, ++np)
+ {
+ if (move)
+ {
+ cpoints[0] = pt;
+ move = ((bool) 0);
+ }
+ else
+ {
+ switch (off_curve++)
+ {
+ default:
+ cpoints[2].x = ((cpoints[1].x + pt.x) / 2);
+ cpoints[2].y = ((cpoints[1].y + pt.y) / 2);
+ code =
+ gx_path_add_curve_notes (ppath,
+ ((cpoints[0].x +
+ 2 * cpoints[1].x) / 3),
+ ((cpoints[0].y +
+ 2 * cpoints[1].y) / 3),
+ ((2 * cpoints[1].x +
+ cpoints[2].x) / 3),
+ ((2 * cpoints[1].y +
+ cpoints[2].y) / 3),
+ cpoints[2].x, cpoints[2].y,
+ 0);
+ cpoints[0] = cpoints[2];
+ case 0:
+ cpoints[1] = pt;
+ }
+ }
+ }
+ }
+ }
+}
+int
+append_outline (uint glyph_index, const gs_matrix_fixed *pmat, void *ppath)
+{
+ gs_const_string glyph_string = {0};
+ int numContours = 0;
+ numContours =
+ (int) (((((uint) ((glyph_string.data)[0]) << 8) +
+ (glyph_string.data)[1]) ^ 0x8000) - 0x8000);
+ if (numContours >= 0)
+ return append_simple (glyph_string.data, pmat, ppath);
+ {
+ uint flags = 0;
+ do
+ {
+ gs_matrix_fixed mat = {0};
+ gs_matrix scale_mat = {0};
+ gs_matrix_multiply (&scale_mat, (const gs_matrix *) &mat, (gs_matrix *) & mat);
+ }
+ while (flags & 32);
+ }
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr39074-2.c b/gcc/testsuite/gcc.dg/torture/pr39074-2.c
new file mode 100644
index 000000000..a90c5643d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr39074-2.c
@@ -0,0 +1,34 @@
+/* { dg-do run } */
+/* { dg-require-effective-target stdint_types } */
+/* { dg-options "-fdump-tree-alias" } */
+/* { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */
+
+#include <stdint.h>
+
+int i;
+uintptr_t __attribute__((noinline,const)) bar(int ***p) { return (uintptr_t)p; }
+void __attribute__((noinline))
+foo(void)
+{
+ int *y;
+ int **a = &y, **x;
+ int ***p;
+ uintptr_t b;
+ b = bar(&a);
+ p = (int ***)b;
+ x = *p;
+ *x = &i; /* *ANYTHING = &i has to make sure that y points to i. */
+ *y = 0;
+}
+extern void abort (void);
+int main()
+{
+ i = 1;
+ foo ();
+ if (i != 0)
+ abort ();
+ return 0;
+}
+
+/* { dg-final { scan-tree-dump "y.._., points-to vars: { i }" "alias" } } */
+/* { dg-final { cleanup-tree-dump "alias" } } */
diff --git a/gcc/testsuite/gcc.dg/torture/pr39074-3.c b/gcc/testsuite/gcc.dg/torture/pr39074-3.c
new file mode 100644
index 000000000..7c7604826
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr39074-3.c
@@ -0,0 +1,25 @@
+/* { dg-do run } */
+/* { dg-require-effective-target stdint_types } */
+
+#include <stdint.h>
+
+uintptr_t __attribute__((noinline,const)) bar(int ***p) { return (uintptr_t)p; }
+extern void abort (void);
+int main()
+{
+ int i, j;
+ int *y = &j;
+ int **a = &y, **x;
+ int ***p;
+ uintptr_t b;
+ b = bar(&a);
+ p = (int ***)b;
+ x = *p;
+ *x = &i;
+ i = 1;
+ *y = 0;
+ if (i != 0)
+ abort ();
+ return 0;
+}
+
diff --git a/gcc/testsuite/gcc.dg/torture/pr39074.c b/gcc/testsuite/gcc.dg/torture/pr39074.c
new file mode 100644
index 000000000..fe35cd908
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr39074.c
@@ -0,0 +1,33 @@
+/* { dg-do run } */
+/* { dg-options "-fdump-tree-alias" } */
+/* { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */
+
+typedef __PTRDIFF_TYPE__ intptr_t;
+
+int i;
+void __attribute__((noinline))
+foo(long b, intptr_t q)
+{
+ int *y;
+ int **a = &y, **x;
+ int ***p;
+ if (b)
+ p = (int ***)q;
+ else
+ p = &a;
+ x = *p;
+ *x = &i; /* *ANYTHING = &i has to make sure that y points to i. */
+ *y = 0;
+}
+extern void abort (void);
+int main()
+{
+ i = 1;
+ foo (0, 0);
+ if (i != 0)
+ abort ();
+ return 0;
+}
+
+/* { dg-final { scan-tree-dump "y.._., points-to vars: { i }" "alias" } } */
+/* { dg-final { cleanup-tree-dump "alias" } } */
diff --git a/gcc/testsuite/gcc.dg/torture/pr39132.c b/gcc/testsuite/gcc.dg/torture/pr39132.c
new file mode 100644
index 000000000..f6e2907e0
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr39132.c
@@ -0,0 +1,34 @@
+/* { dg-do run } */
+/* { dg-options "-ftree-loop-distribution" } */
+
+extern void abort(void);
+
+struct epic_private
+{
+ unsigned int *rx_ring;
+ unsigned int rx_skbuff[5];
+};
+
+int
+main (void)
+{
+ struct epic_private ep;
+ unsigned int rx_ring[5];
+ int i;
+
+ ep.rx_skbuff[0] = 5;
+
+ ep.rx_ring = rx_ring;
+
+ for (i = 0; i < 5; i++)
+ {
+ ep.rx_ring[i] = i;
+ ep.rx_skbuff[i] = 0;
+ }
+
+ if (ep.rx_skbuff[0] != 0)
+ abort ();
+
+ return 0;
+}
+
diff --git a/gcc/testsuite/gcc.dg/torture/pr39204.c b/gcc/testsuite/gcc.dg/torture/pr39204.c
new file mode 100644
index 000000000..1389a52ec
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr39204.c
@@ -0,0 +1,131 @@
+/* { dg-do compile } */
+/* { dg-options "-w" } */
+
+__extension__ typedef __SIZE_TYPE__ size_t;
+typedef unsigned char __u_char;
+typedef unsigned short int __u_short;
+typedef unsigned int __u_int;
+typedef unsigned long int __u_long;
+typedef signed char __int8_t;
+typedef unsigned char __uint8_t;
+typedef signed short int __int16_t;
+typedef unsigned short int __uint16_t;
+typedef signed int __int32_t;
+typedef unsigned int __uint32_t;
+__extension__ typedef signed long long int __int64_t;
+__extension__ typedef unsigned long long int __uint64_t;
+__extension__ typedef long long int __quad_t;
+__extension__ typedef unsigned long long int __u_quad_t;
+__extension__ typedef __u_quad_t __dev_t;
+__extension__ typedef unsigned int __uid_t;
+__extension__ typedef unsigned int __gid_t;
+__extension__ typedef unsigned long int __ino_t;
+__extension__ typedef __u_quad_t __ino64_t;
+__extension__ typedef unsigned int __mode_t;
+__extension__ typedef unsigned int __nlink_t;
+__extension__ typedef long int __off_t;
+__extension__ typedef __quad_t __off64_t;
+__extension__ typedef int __pid_t;
+__extension__ typedef struct {
+ int __val[2];
+} __fsid_t;
+__extension__ typedef long int __clock_t;
+__extension__ typedef unsigned int __id_t;
+typedef struct _IO_FILE FILE;
+typedef struct _IO_FILE __FILE;
+typedef struct {
+ int __count;
+ union {
+ unsigned int __wch;
+ char __wchb[4];
+ }
+ __value;
+} __mbstate_t;
+typedef struct {
+ __off_t __pos;
+ __mbstate_t __state;
+} _G_fpos_t;
+typedef struct {
+ __off64_t __pos;
+ __mbstate_t __state;
+} _G_fpos64_t;
+typedef unsigned int _G_uint16_t __attribute__ ((__mode__ (__HI__)));
+typedef struct _IO_FILE _IO_FILE;
+extern struct _IO_FILE_plus _IO_2_1_stderr_;
+extern int fputs (__const char *__restrict __s, FILE * __restrict __stream);
+extern char *strstr (__const char *__haystack, __const char *__needle)
+ __attribute__ ((__nonnull__ (1, 2)));
+ extern char *rindex (__const char *__s, int __c) __attribute__ ((__nonnull__ (1)));
+extern size_t strlen (__const char *__s) __attribute__ ((__nothrow__))
+ __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
+ char *mystrlwr (char *string);
+ char *m_replace_filename (const char *path, const char *filename);
+ typedef struct LINE {
+ char *text;
+ struct LINE *next;
+ int flags;
+ } LINE;
+typedef struct TOC {
+ char *text;
+ char *alt;
+ struct TOC *next;
+ int root;
+ int texinfoable;
+ int htmlable;
+ int otherfile;
+} TOC;
+static int _empty_count;
+extern char *_word_substitution[256];
+static void _output_sorted_nested_toc (TOC ** list, unsigned int num_items);
+static char *_do_text_substitution (char *input);
+static int _toc_scmp (const void *e1, const void *e2)
+{
+ TOC *t1 = *((TOC **) e1);
+ TOC *t2 = *((TOC **) e2);
+ return mystricmp (t1->text, t2->text);
+}
+static void _output_buffered_text (void) { if (_empty_count) ; }
+void _post_process_filename (char *filename)
+{
+ int code_scanning = 0;
+ char *new_filename, *p;
+ char *line;
+ FILE *f1 = 0, *f2 = 0;
+ if (!new_filename || strlen (new_filename) < 2)
+ new_filename[strlen (filename) - 1] = 'x';
+ if (!f1 || !f2)
+ while ((line = m_fgets (f1)))
+ {
+ line = _do_text_substitution (line);
+ fputs (line, f2);
+ }
+ if (remove (filename))
+ cancel:
+ if (f1)
+ if (f2)
+ if (new_filename)
+ ;
+}
+static void _close_html_file (FILE * file)
+{
+ int f;
+ for (f = 0; _word_substitution[f]; f++)
+ ;
+}
+static __attribute__((always_inline))
+char * _do_text_substitution (char *input)
+{
+ int start, end, middle, f;
+ char *temp, *found, *reader;
+ for (f = 0; _word_substitution[f]; f++)
+ {
+ reader = input;
+ while ((found = strstr (reader, _word_substitution[f])))
+ {
+ start = found - input;
+ input = temp;
+ reader = temp + start + middle;
+ }
+ }
+ return input;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr39241.c b/gcc/testsuite/gcc.dg/torture/pr39241.c
new file mode 100644
index 000000000..860a04d73
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr39241.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-options "-w" } */
+
+static inline int
+foo (float f)
+{
+ return *((int *) &f) - 1;
+}
+
+float
+bar (float x, float y, float *z)
+{
+ float c = y < 0.002f ? 0.002f : y;
+ float d = x < c ? c : x;
+ return z[foo (c)] + z[foo (d * 255.0f)];
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr39678.c b/gcc/testsuite/gcc.dg/torture/pr39678.c
new file mode 100644
index 000000000..5411fbbc1
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr39678.c
@@ -0,0 +1,27 @@
+/* PR target/39678 */
+/* { dg-do run } */
+/* { dg-options "-Wno-psabi" } */
+
+struct X {
+ signed char c;
+ __complex__ float val;
+};
+
+struct X __attribute__((noinline))
+foo (float *p)
+{
+ struct X x;
+ x.c = -3;
+ __real x.val = p[0];
+ __imag x.val = p[1];
+ return x;
+}
+extern void abort (void);
+float a[2] = { 3., -2. };
+int main()
+{
+ struct X x = foo(a);
+ if (x.c != -3 || __real x.val != a[0] || __imag x.val != a[1])
+ abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr39829.c b/gcc/testsuite/gcc.dg/torture/pr39829.c
new file mode 100644
index 000000000..da15a56e1
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr39829.c
@@ -0,0 +1,27 @@
+/* { dg-do compile } */
+/* { dg-options "-w" } */
+
+void foo (void * DAG_temp117584)
+{
+ char uA;
+ void* pA;
+ void* pB;
+ void* pC;
+ do {
+ int DAG_temp117585;
+ int DAG_temp117586;
+ void ** __indir_union1 = (void**)DAG_temp117584;
+ DAG_temp117585 = (long)*__indir_union1;
+ DAG_temp117586 = DAG_temp117585;
+ if ( DAG_temp117586 != (int)268435456 )
+ pA = (void*)&uA;
+ pB = (void*)&pA;
+ pC = pB;
+ union __block_indir0_u { struct { long val; } __indir_struct; }
+ * __indir_union = (union __block_indir0_u*)pC;
+ f(__indir_union->__indir_struct.val);
+
+ DAG_temp117584 += 64;
+ } while (1);
+}
+
diff --git a/gcc/testsuite/gcc.dg/torture/pr39855.c b/gcc/testsuite/gcc.dg/torture/pr39855.c
new file mode 100644
index 000000000..6d75c38a9
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr39855.c
@@ -0,0 +1,24 @@
+/* PR c/39855 */
+/* { dg-do run { target { int32plus } } } */
+
+extern void abort (void);
+
+int i, j, k;
+
+int
+foo (void)
+{
+ return ++i;
+}
+
+int
+main ()
+{
+ if (__CHAR_BIT__ != 8 || sizeof (int) != 4)
+ return 0;
+ j = foo () << 30 << 2;
+ k = (unsigned) foo () >> 16 >> 16;
+ if (i != 2 || j != 0 || k != 0)
+ abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr39903-1.c b/gcc/testsuite/gcc.dg/torture/pr39903-1.c
new file mode 100644
index 000000000..1a67dd795
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr39903-1.c
@@ -0,0 +1,24 @@
+/* PR target/39903 */
+/* { dg-do run } */
+/* { dg-options "-Wno-psabi" } */
+
+struct X {
+ double d;
+ double b[];
+};
+
+struct X __attribute__((noinline))
+foo (double d)
+{
+ struct X x;
+ x.d = d;
+ return x;
+}
+extern void abort (void);
+int main()
+{
+ struct X x = foo(3.0);
+ if (x.d != 3.0)
+ abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr39903-2.c b/gcc/testsuite/gcc.dg/torture/pr39903-2.c
new file mode 100644
index 000000000..0cd74029b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr39903-2.c
@@ -0,0 +1,24 @@
+/* PR target/39903 */
+/* { dg-do run } */
+/* { dg-options "-Wno-psabi" } */
+
+struct X {
+ float d;
+ float b[];
+};
+
+struct X __attribute__((noinline))
+foo (float d)
+{
+ struct X x;
+ x.d = d;
+ return x;
+}
+extern void abort (void);
+int main()
+{
+ struct X x = foo(3.0);
+ if (x.d != 3.0)
+ abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr40328.c b/gcc/testsuite/gcc.dg/torture/pr40328.c
new file mode 100644
index 000000000..e378e63c0
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr40328.c
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options "-fno-tree-sra" } */
+
+_Complex float foo(void)
+{
+ _Complex float a[64] = {};
+ _Complex float x;
+ x = a[1];
+ return x;
+}
+
diff --git a/gcc/testsuite/gcc.dg/torture/pr40470-1.c b/gcc/testsuite/gcc.dg/torture/pr40470-1.c
new file mode 100644
index 000000000..cb2510e88
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr40470-1.c
@@ -0,0 +1,22 @@
+/* { dg-do compile { target i?86-*-* x86_64-*-* } } */
+/* { dg-options "-msse4" } */
+#include <nmmintrin.h>
+__m128i load (char *);
+char *
+foo (char *p1, char *p2,
+ int bmsk, __m128i mask1, __m128i mask2)
+{
+ int len = 0;
+ __m128i frag1, frag2;
+ int cmp_s;
+ if( !p2[0]) return p1;
+ if( !p1[0] ) return NULL;
+ frag2 = load (p2);
+ frag1 = load (p1);
+ frag2 = _mm_blendv_epi8(frag2, mask2, mask1);
+ frag1 = _mm_blendv_epi8(frag1, mask2, mask1);
+ cmp_s = _mm_cmpistrs(frag2, frag1, 0x0c);
+ if( cmp_s )
+ __asm("bsfl %[bmsk], %[len]" : [len] "=r" (len) : [bmsk] "r" (bmsk) );
+ return p1 + len;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr40470-2.c b/gcc/testsuite/gcc.dg/torture/pr40470-2.c
new file mode 100644
index 000000000..b0414bbea
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr40470-2.c
@@ -0,0 +1,27 @@
+/* { dg-do compile { target i?86-*-* x86_64-*-* } } */
+/* { dg-options "-msse4" } */
+#include <nmmintrin.h>
+__m128i load (char *);
+char *
+foo (const unsigned char *s1, const unsigned char *s2,
+ int bmsk, __m128i frag2)
+{
+ int len = 0;
+ char *p1 = (char *) s1;
+ char *p2 = (char *) s2;
+ __m128i frag1, fruc, mask;
+ int cmp_c, cmp_s;
+ if( !p2[0]) return (char *) s1;
+ if( !p1[0] ) return NULL;
+ if( p2[1]) frag2 = load (p2);
+ frag1 = load (p1);
+ fruc = _mm_loadu_si128 ((__m128i *) s1);
+ mask = _mm_cmpistrm(fruc, frag2, 0x44);
+ frag2 = _mm_blendv_epi8(frag2, mask, mask);
+ frag1 = _mm_blendv_epi8(frag1, mask, mask);
+ cmp_c = _mm_cmpistrc(frag2, frag1, 0x0c);
+ cmp_s = _mm_cmpistrs(frag2, frag1, 0x0c);
+ if( cmp_s & cmp_c )
+ __asm("bsfl %[bmsk], %[len]" : [len] "=r" (len) : [bmsk] "r" (bmsk) );
+ return p2 + len;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr40470-3.c b/gcc/testsuite/gcc.dg/torture/pr40470-3.c
new file mode 100644
index 000000000..5c4c361de
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr40470-3.c
@@ -0,0 +1,22 @@
+/* { dg-do compile { target i?86-*-* x86_64-*-* } } */
+/* { dg-options "-msse4" } */
+#include <nmmintrin.h>
+__m128i load (char *);
+char *
+foo (char *p1, char *p2,
+ int bmsk, __m128i mask1, __m128i mask2)
+{
+ int len = 0;
+ __m128i frag1, frag2;
+ int cmp_s;
+ if( !p2[0]) return p1;
+ if( !p1[0] ) return NULL;
+ frag2 = load (p2);
+ frag1 = load (p1);
+ frag2 = _mm_blendv_epi8(frag2, mask2, mask1);
+ frag1 = _mm_blendv_epi8(frag1, mask1, mask2);
+ cmp_s = _mm_cmpistrs(frag2, frag1, 0x0c);
+ if( cmp_s )
+ __asm("bsfl %[bmsk], %[len]" : [len] "=r" (len) : [bmsk] "r" (bmsk) );
+ return p1 + len;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr40470-4.c b/gcc/testsuite/gcc.dg/torture/pr40470-4.c
new file mode 100644
index 000000000..f9d0e5095
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr40470-4.c
@@ -0,0 +1,29 @@
+/* { dg-do compile { target i?86-*-* x86_64-*-* } } */
+/* { dg-options "-msse4" } */
+#include <nmmintrin.h>
+__m128i load (char *);
+char *
+foo (const unsigned char *s1, const unsigned char *s2,
+ int bmsk, __m128i frag2)
+{
+ int len = 0;
+ char *p1 = (char *) s1;
+ char *p2 = (char *) s2;
+ __m128i frag1, fruc1, fruc2, mask1, mask2;
+ int cmp_c, cmp_s;
+ if( !p2[0]) return (char *) s1;
+ if( !p1[0] ) return NULL;
+ if( p2[1]) frag2 = load (p2);
+ frag1 = load (p1);
+ fruc1 = _mm_loadu_si128 ((__m128i *) s1);
+ fruc2 = _mm_loadu_si128 ((__m128i *) s2);
+ mask1 = _mm_cmpistrm(fruc1, frag2, 0x44);
+ mask2 = _mm_cmpistrm(fruc2, frag1, 0x14);
+ frag2 = _mm_blendv_epi8(frag2, mask1, mask2);
+ frag1 = _mm_blendv_epi8(frag1, mask2, mask1);
+ cmp_c = _mm_cmpistrc(frag2, frag1, 0x0c);
+ cmp_s = _mm_cmpistrs(frag2, frag1, 0x0c);
+ if( cmp_s & cmp_c )
+ __asm("bsfl %[bmsk], %[len]" : [len] "=r" (len) : [bmsk] "r" (bmsk) );
+ return p2 + len;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr41094.c b/gcc/testsuite/gcc.dg/torture/pr41094.c
new file mode 100644
index 000000000..2a4e9616c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr41094.c
@@ -0,0 +1,19 @@
+/* { dg-do run } */
+/* { dg-options "-ffast-math" } */
+
+#include <math.h>
+
+extern void abort (void);
+
+double foo(void)
+{
+ double x = -4.0;
+ return pow (x * x, 0.25);
+}
+
+int main()
+{
+ if (foo() != 2.0)
+ abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr41261.c b/gcc/testsuite/gcc.dg/torture/pr41261.c
new file mode 100644
index 000000000..8e601555c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr41261.c
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+/* { dg-options "-fprofile-arcs" } */
+
+extern void relocate_kernel();
+void machine_kexec(void *control_page)
+{
+ __builtin_memcpy(control_page, relocate_kernel, 2048);
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr41555.c b/gcc/testsuite/gcc.dg/torture/pr41555.c
new file mode 100644
index 000000000..c201fda0c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr41555.c
@@ -0,0 +1,119 @@
+/* { dg-do run } */
+/* { dg-options "-std=c99" } */
+
+#include <stdint.h>
+#include <limits.h>
+
+extern void abort (void);
+
+static uint64_t safe_div_func_uint64_t_u_u (uint64_t _ui1, uint64_t _ui2)
+{
+ if (_ui2==0) return _ui1;
+ return _ui1 / _ui2;
+}
+
+static int64_t safe_div_func_int64_t_s_s (int64_t _si1, int64_t _si2)
+{
+ if (_si2==0 || (_si1==INT64_MIN && _si2==-1)) return _si1;
+ return _si1 / _si2;
+}
+
+#define safe_add_macro_int8_t_s_s(si1,si2) \
+ ((((((int8_t)(si1))>((int8_t)0)) && (((int8_t)(si2))>((int8_t)0)) && (((int8_t)(si1)) > ((INT8_MAX)-((int8_t)(si2))))) \
+ || ((((int8_t)(si1))<((int8_t)0)) && (((int8_t)(si2))<((int8_t)0)) && (((int8_t)(si1)) < ((INT8_MIN)-((int8_t)(si2)))))) \
+ ? ((int8_t)(si1)) \
+ : (((int8_t)(si1)) + ((int8_t)(si2))) \
+ )
+
+static int8_t
+safe_add_func_int8_t_s_s(int8_t _si1, int8_t _si2)
+{
+ return safe_add_macro_int8_t_s_s(_si1,_si2);
+}
+
+#define safe_rshift_macro_uint64_t_u_s(left,right) \
+ (((((int)(right)) < ((uint64_t)0)) \
+ || (((int)(right)) >= sizeof(uint64_t)*CHAR_BIT)) \
+ ? ((uint64_t)(left)) \
+ : (((uint64_t)(left)) >> ((int)(right))))
+
+static uint64_t
+safe_rshift_func_uint64_t_u_s(uint64_t _left, int _right)
+{
+ return safe_rshift_macro_uint64_t_u_s(_left,_right);
+}
+
+#define safe_mul_macro_int32_t_s_s(si1,si2) \
+ ((((((int32_t)(si1)) > ((int32_t)0)) && (((int32_t)(si2)) > ((int32_t)0)) && (((int32_t)(si1)) > ((INT32_MAX) / ((int32_t)(si2))))) || \
+ ((((int32_t)(si1)) > ((int32_t)0)) && (((int32_t)(si2)) <= ((int32_t)0)) && (((int32_t)(si2)) < ((INT32_MIN) / ((int32_t)(si1))))) || \
+ ((((int32_t)(si1)) <= ((int32_t)0)) && (((int32_t)(si2)) > ((int32_t)0)) && (((int32_t)(si1)) < ((INT32_MIN) / ((int32_t)(si2))))) || \
+ ((((int32_t)(si1)) <= ((int32_t)0)) && (((int32_t)(si2)) <= ((int32_t)0)) && (((int32_t)(si1)) != ((int32_t)0)) && (((int32_t)(si2)) < ((INT32_MAX) / ((int32_t)(si1)))))) \
+ ? ((int32_t)(si1)) \
+ : ((int32_t)(si1)) * ((int32_t)(si2)))
+
+static int32_t
+safe_mul_func_int32_t_s_s (int32_t _si1, int32_t _si2)
+{
+ return safe_mul_macro_int32_t_s_s(_si1,_si2);
+}
+
+static int8_t g_39;
+static volatile uint8_t g_46;
+static uint8_t g_47;
+static uint8_t *g_62;
+static uint8_t g_79;
+static int8_t g_101 = -1L;
+static uint8_t *g_114;
+static uint8_t *g_126;
+static uint8_t g_133;
+
+static uint16_t func_35 (int32_t * p_36, uint64_t p_37, uint32_t p_38);
+static uint16_t func_35 (int32_t * p_36, uint64_t p_37, uint32_t p_38)
+{
+ if (g_62 != 0)
+ abort ();
+ for (g_39 = 1; g_39 < 0; g_39 = 1)
+ {
+ }
+ return 1;
+}
+
+static int32_t func_19 (int32_t p_20);
+static int32_t func_19 (int32_t p_20)
+{
+ if (1 !=
+ safe_div_func_uint64_t_u_u ((safe_div_func_int64_t_s_s (p_20, 1)),
+ g_101))
+ {
+ func_35 (0, 1 <= (safe_add_func_int8_t_s_s (g_47, g_46)) > p_20 < 1, 1);
+ g_133 = 1;
+ if (g_114 != 0)
+ abort ();
+ if (g_126 != 0)
+ abort ();
+ }
+ return 1;
+}
+
+static uint8_t func_2 (int32_t p_6);
+static uint8_t func_2 (int32_t p_6)
+{
+ for (1; p_6 > 1; 1)
+ return 0;
+ func_19 (g_79);
+ if (safe_mul_func_int32_t_s_s
+ ((0, 1 < (safe_rshift_func_uint64_t_u_s (1 ^ p_6, 1))),
+ (func_35 (&p_6, 1, 1) < 1)))
+ {
+ }
+ return 1;
+}
+
+int main (void)
+{
+ func_2 (1);
+ if (g_133 != 1)
+ abort ();
+ return 0;
+}
+
diff --git a/gcc/testsuite/gcc.dg/torture/pr42363.c b/gcc/testsuite/gcc.dg/torture/pr42363.c
new file mode 100644
index 000000000..9c9da1373
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr42363.c
@@ -0,0 +1,84 @@
+/* PR middle-end/pr42363, extended from the test for PR middle-end/37913. */
+/* { dg-do compile } */
+/* { dg-options "-g" } */
+
+void foo (void) __attribute__ ((noreturn));
+
+static int __attribute__ ((noreturn))
+bar (void)
+{
+ foo ();
+}
+
+int
+baz (void)
+{
+ int i = bar ();
+ return i + 1;
+}
+
+int fooz (void) __attribute__ ((noreturn));
+
+static int __attribute__ ((noreturn))
+bart (void)
+{
+ return fooz (); /* { dg-warning "noreturn" } */
+}
+
+int bazr (void)
+{
+ int i = bart ();
+ return i + 1;
+}
+
+static inline int
+bard (void)
+{
+ return fooz ();
+}
+
+int bizr (void)
+{
+ int i, j;
+
+ i = j = bard ();
+
+ return i + 1;
+}
+
+/* This might be regarded as pure and folded, rather than inlined.
+ It's pure evil. */
+static int __attribute__ ((pure, const, noreturn))
+barf (void)
+{
+} /* { dg-warning "does return" } */
+
+static int __attribute__ ((pure, const))
+bark (void)
+{
+ barf ();
+}
+
+int buzr (void)
+{
+ int i, j;
+
+ i = j = bark () + bark ();
+
+ return i + 1;
+}
+
+int buzt (void)
+{
+ int i, j;
+
+ i = j = barf () + barf ();
+
+ return i + 1;
+}
+
+void bust (void)
+{
+ while (barf ())
+ ;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr42667.c b/gcc/testsuite/gcc.dg/torture/pr42667.c
new file mode 100644
index 000000000..eac80014b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr42667.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-w" } */
+
+extern int strlen(const char *);
+void WriteTextDots(int len);
+
+void OnDisplay(char * string)
+{
+ if (!string)
+ string = "(none)";
+ WriteTextDots(strlen(string));
+}
+
diff --git a/gcc/testsuite/gcc.dg/torture/pr42878-1.c b/gcc/testsuite/gcc.dg/torture/pr42878-1.c
new file mode 100644
index 000000000..8c21f0f60
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr42878-1.c
@@ -0,0 +1,30 @@
+/* { dg-do compile } */
+/* { dg-options "-fcompare-debug" } */
+
+struct S {
+ int i;
+};
+
+extern struct S *e1(void);
+extern int e2(int i);
+
+static inline void f1()
+{
+ int i;
+ struct S *s;
+ for (i = 0; i < 10; i++)
+ s = e1();
+ e2(s->i);
+}
+
+static inline void f2(int i)
+{
+ int j = j;
+ j = e2(i);
+}
+
+void foo(int i)
+{
+ f1();
+ f2(i);
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr42878-2.c b/gcc/testsuite/gcc.dg/torture/pr42878-2.c
new file mode 100644
index 000000000..67e413a2c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr42878-2.c
@@ -0,0 +1,34 @@
+/* { dg-do compile } */
+/* { dg-options "-fcompare-debug" } */
+
+extern void error(void) __attribute__((noreturn));
+
+struct S {
+ struct S *s;
+};
+
+static inline unsigned char f2()
+{
+ error();
+}
+
+static inline void f1()
+{
+ int builtin_optab;
+ if (!f2() && builtin_optab)
+ error();
+}
+
+extern void f4(struct S *s);
+
+static inline void f3(struct S *s)
+{
+ f4(s->s->s);
+}
+
+void expand_builtin(struct S *s, int cond)
+{
+ if (cond)
+ f1();
+ f3(s);
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr42898-2.c b/gcc/testsuite/gcc.dg/torture/pr42898-2.c
new file mode 100644
index 000000000..f90a85ea6
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr42898-2.c
@@ -0,0 +1,25 @@
+/* { dg-do compile } */
+/* { dg-options "-fdump-tree-optimized" } */
+
+struct hardware {
+ int parm1:8;
+ int :4;
+ int parm2:4;
+ int parm3:15;
+ int parm4:1;
+};
+
+const struct hardware h = {
+ .parm1=42,
+ .parm2=13,
+ .parm3=11850,
+ .parm4=1,
+};
+
+void f1(volatile struct hardware *ptr)
+{
+ *ptr = h;
+}
+
+/* { dg-final { scan-tree-dump-times "\\*ptr" 1 "optimized" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
diff --git a/gcc/testsuite/gcc.dg/torture/pr42898.c b/gcc/testsuite/gcc.dg/torture/pr42898.c
new file mode 100644
index 000000000..df8b46a62
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr42898.c
@@ -0,0 +1,23 @@
+/* { dg-do compile } */
+/* { dg-options "-fdump-tree-optimized" } */
+
+struct hardware {
+ int parm1:8;
+ int :4;
+ int parm2:4;
+ int parm3:15;
+ int parm4:1;
+};
+
+void f1(volatile struct hardware *ptr)
+{
+ *ptr=(struct hardware) {
+ .parm1=42,
+ .parm2=13,
+ .parm3=11850,
+ .parm4=1,
+ };
+}
+
+/* { dg-final { scan-tree-dump-times "\\*ptr" 1 "optimized" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
diff --git a/gcc/testsuite/gcc.dg/torture/pr42952.c b/gcc/testsuite/gcc.dg/torture/pr42952.c
new file mode 100644
index 000000000..db8782af3
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr42952.c
@@ -0,0 +1,19 @@
+/* { dg-do run } */
+/* { dg-options "-fno-tree-ccp -fno-tree-fre" } */
+
+extern void abort (void);
+
+static int g[1];
+
+static int * const p = &g[0];
+static int * const q = &g[0];
+
+int main(void)
+{
+ g[0] = 1;
+ *p = 0;
+ *p = *q;
+ if (g[0] != 0)
+ abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr43000.c b/gcc/testsuite/gcc.dg/torture/pr43000.c
new file mode 100644
index 000000000..c11233750
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr43000.c
@@ -0,0 +1,24 @@
+/* { dg-do run } */
+/* { dg-options "-fwrapv" } */
+
+int __attribute__((noinline))
+foo (long i, long j)
+{
+ if (i >= 1)
+ if (j > -(long)(((unsigned long)(long)-1)>>1))
+ {
+ long x;
+ j--;
+ x = i + j;
+ if (x >= 0)
+ return 1;
+ }
+ return 0;
+}
+extern void abort (void);
+int main()
+{
+ if (foo (1, 1) != 1)
+ abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr43002.c b/gcc/testsuite/gcc.dg/torture/pr43002.c
new file mode 100644
index 000000000..f28a9102b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr43002.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-options "-Wall -fwrapv" } */
+
+long A[4], B[100];
+
+void foo(void)
+{
+ int i, j, k = 3;
+ while (A[k] && k > 0) k--; /* k = {0, 1, 2, 3} */
+ for (i = 3 - k; i >= 0; i--) /* i = {0..3-k} */
+ for (j = 0; j <= k; j++) { /* line 8; j = {0..k} */
+ B[i + j] = 0; /* line 9; i + j = {0..3-k+k} = {0..3} */
+ for (j = 0; j <= k; j++); /* only one iteration is done, with j == 0 */
+ }
+}
+
diff --git a/gcc/testsuite/gcc.dg/torture/pr43017.c b/gcc/testsuite/gcc.dg/torture/pr43017.c
new file mode 100644
index 000000000..257945290
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr43017.c
@@ -0,0 +1,99 @@
+/* { dg-do run } */
+/* { dg-options "-fwrapv" } */
+
+signed char foo(unsigned char c2)
+{
+ signed char c2_22;
+
+ if (c2 <= 63 || c2 == 127)
+ goto bb43;
+ else
+ goto bb20;
+
+bb20:
+ if (c2 > 252)
+ goto bb43;
+ else
+ goto bb21;
+
+bb21:
+ /*...*/;
+
+bb24:
+ c2_22 = (signed char)c2;
+ if (c2_22 >= 0)
+ goto bb25;
+ else
+ goto bb26;
+
+bb25:
+ c2 = (unsigned char)(c2_22 - 64);
+ goto bb27;
+
+bb26:
+ c2 = (unsigned char)(c2_22 - 65);
+
+bb27:
+ if (c2 <= 93)
+ goto bb28;
+ else
+ goto bb29;
+
+bb28:
+ c2 = c2 + 33;
+ goto bb30;
+
+bb29:
+ c2 = (unsigned char)((signed char)c2 - 61);
+
+bb30:
+ return c2;
+
+bb43:
+ return -1;
+}
+extern void abort (void);
+int main()
+{
+ signed char res[256] = {
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ 33, 34, 35, 36, 37, 38, 39, 40,
+ 41, 42, 43, 44, 45, 46, 47, 48,
+ 49, 50, 51, 52, 53, 54, 55, 56,
+ 57, 58, 59, 60, 61, 62, 63, 64,
+ 65, 66, 67, 68, 69, 70, 71, 72,
+ 73, 74, 75, 76, 77, 78, 79, 80,
+ 81, 82, 83, 84, 85, 86, 87, 88,
+ 89, 90, 91, 92, 93, 94, 95, -1,
+ 96, 97, 98, 99, 100, 101, 102, 103,
+ 104, 105, 106, 107, 108, 109, 110, 111,
+ 112, 113, 114, 115, 116, 117, 118, 119,
+ 120, 121, 122, 123, 124, 125, 126, 33,
+ 34, 35, 36, 37, 38, 39, 40, 41,
+ 42, 43, 44, 45, 46, 47, 48, 49,
+ 50, 51, 52, 53, 54, 55, 56, 57,
+ 58, 59, 60, 61, 62, 63, 64, 65,
+ 66, 67, 68, 69, 70, 71, 72, 73,
+ 74, 75, 76, 77, 78, 79, 80, 81,
+ 82, 83, 84, 85, 86, 87, 88, 89,
+ 90, 91, 92, 93, 94, 95, 96, 97,
+ 98, 99, 100, 101, 102, 103, 104, 105,
+ 106, 107, 108, 109, 110, 111, 112, 113,
+ 114, 115, 116, 117, 118, 119, 120, 121,
+ 122, 123, 124, 125, 126, -1, -1, -1
+ };
+ unsigned int c;
+ for (c = 0; c <= 255; ++c)
+ {
+ if (foo (c) != res[c])
+ abort ();
+ }
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr43165.c b/gcc/testsuite/gcc.dg/torture/pr43165.c
new file mode 100644
index 000000000..637fb4646
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr43165.c
@@ -0,0 +1,17 @@
+/* PR debug/43165 */
+/* { dg-options "-g" } */
+
+struct __attribute__((packed)) S
+{
+ unsigned char a;
+ unsigned short b;
+ unsigned short c;
+ unsigned d : 24;
+};
+
+void
+foo (struct S p)
+{
+ for (; p.c; p.c++)
+ ;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr43360.c b/gcc/testsuite/gcc.dg/torture/pr43360.c
new file mode 100644
index 000000000..9ed9872db
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr43360.c
@@ -0,0 +1,20 @@
+/* { dg-do run } */
+
+int l_5_5_2 = 4;
+int g_3[1][1];
+
+void func_1 (void)
+{
+ for (g_3[0][0] = 1; g_3[0][0] < 8; g_3[0][0] += 7) {
+ int *l_6 = &g_3[0][0];
+ *l_6 = l_5_5_2;
+ }
+}
+
+int main (void)
+{
+ func_1 ();
+ if (g_3[0][0] != 11)
+ __builtin_abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr43560.c b/gcc/testsuite/gcc.dg/torture/pr43560.c
new file mode 100644
index 000000000..44abb80b1
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr43560.c
@@ -0,0 +1,34 @@
+/* { dg-do run } */
+/* { dg-require-weak "" } */
+
+int g_6[1][2] = {{1,1}};
+int g_34 = 0;
+int *const g_82 = &g_6[0][1];
+int *g_85[2][1] __attribute__((weak));
+
+void __attribute__((noinline))
+func_4 (int x)
+{
+ int i;
+ for (i = 0; i <= x; i++) {
+ if (g_6[0][1]) {
+ *g_82 = 1;
+ } else {
+ int **l_109 = &g_85[1][0];
+ if (&g_82 != l_109) {
+ } else {
+ *l_109 = &g_6[0][1];
+ }
+ *g_82 = 1;
+ }
+ }
+}
+
+int main (void)
+{
+ g_85[0][0] = &g_34;
+ g_85[1][0] = &g_34;
+ func_4(1);
+ return 0;
+}
+
diff --git a/gcc/testsuite/gcc.dg/torture/pr43781.c b/gcc/testsuite/gcc.dg/torture/pr43781.c
new file mode 100644
index 000000000..37fe5a367
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr43781.c
@@ -0,0 +1,45 @@
+/* { dg-do compile } */
+
+typedef int int32_t;
+typedef unsigned char uint8_t;
+
+struct S0
+{
+ uint8_t f3;
+};
+
+struct S2
+{
+ uint8_t f5;
+};
+
+struct S0 g_22 = {
+ 0
+};
+
+int32_t g_91;
+const struct S2 *g_314;
+const struct S2 **g_313 = &g_314;
+struct S2 g_320[2] = {
+ 0
+};
+
+void
+int32func (uint64p_34)
+{
+ for (g_22.f3 = 0; g_22.f3 <= 0; g_22.f3)
+ {
+ lbl_491:{
+ if (1)
+ {
+ int32_t *l_453[2][7][7][1][1];
+ int i, j, k, l, m;
+ for (m; m; m++)
+ l_453[i][j][k][l][m];
+ }
+ *g_313 = 0;
+ if (g_91)
+ goto lbl_491;
+ }
+ }
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr43879-3.c b/gcc/testsuite/gcc.dg/torture/pr43879-3.c
new file mode 100644
index 000000000..5ee80d518
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr43879-3.c
@@ -0,0 +1,41 @@
+/* { dg-do run } */
+/* { dg-options "-fipa-pta" } */
+
+typedef unsigned long ulong;
+
+int __attribute__((noinline, noclone))
+f4 (int a, int b, int c, int d, int e)
+{
+ return a + b + c + d + e;
+}
+
+void __attribute__((noinline, noclone))
+f3 (int *p)
+{
+ *p = f4(1, 2, 3, 4, 5);
+}
+
+void __attribute__((noinline, noclone))
+f2 ()
+{
+ int unused;
+ f3 (&unused);
+}
+
+void __attribute__((noinline, noclone))
+f1 (ulong e, ulong f)
+{
+ if (e > 5 || f > 5) __builtin_abort();
+ f2 ();
+}
+
+
+int main()
+{
+ ulong e, f;
+ for (e = 5; e > 0; e--)
+ for (f = 5; f > 0; f--)
+ f1(e, f);
+ return 0;
+}
+
diff --git a/gcc/testsuite/gcc.dg/torture/pr43879_1.c b/gcc/testsuite/gcc.dg/torture/pr43879_1.c
new file mode 100644
index 000000000..151a184cb
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr43879_1.c
@@ -0,0 +1,27 @@
+/* { dg-do run } */
+/* { dg-options "-fipa-pta" } */
+/* { dg-additional-sources "pr43879_2.c" } */
+
+void bar(int c)
+{
+ static int x = 1;
+ if (c != x) __builtin_abort();
+ x--;
+}
+
+void baz(int *i)
+{
+ (*i)--;
+}
+
+struct TBL {
+ int (*p)(int *i);
+};
+extern struct TBL tbl;
+
+int main()
+{
+ int c = 1;
+ return tbl.p(&c);
+}
+
diff --git a/gcc/testsuite/gcc.dg/torture/pr43879_2.c b/gcc/testsuite/gcc.dg/torture/pr43879_2.c
new file mode 100644
index 000000000..8155653a6
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr43879_2.c
@@ -0,0 +1,17 @@
+struct TBL {
+ int (*p)(int *i);
+};
+
+extern void bar(int i);
+extern void baz(int *i);
+
+static int foo(int *i)
+{
+ bar(*i);
+ baz(i);
+ bar(*i);
+ return *i;
+}
+
+struct TBL tbl = { foo };
+
diff --git a/gcc/testsuite/gcc.dg/torture/pr44050.c b/gcc/testsuite/gcc.dg/torture/pr44050.c
new file mode 100644
index 000000000..931eff6ff
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr44050.c
@@ -0,0 +1,21 @@
+/* { dg-do run } */
+/* { dg-options "-fno-tree-pta" } */
+
+static void __attribute__((noinline))
+foo (int *i, int n)
+{
+ *i = n;
+}
+
+int
+main (void)
+{
+ int i = 0;
+ foo (&i, 1);
+
+ if (i != 1)
+ __builtin_abort ();
+
+ return 0;
+}
+
diff --git a/gcc/testsuite/gcc.dg/torture/pr44695.c b/gcc/testsuite/gcc.dg/torture/pr44695.c
new file mode 100644
index 000000000..85bb4c7b9
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr44695.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+
+typedef unsigned char uint8_t;
+
+static uint8_t
+safe_div_func_uint8_t_u_u (uint8_t ui1, uint8_t ui2)
+{
+ return ui2 ? ui2 : (ui1 / ui2);
+}
+
+int
+int81 (int x)
+{
+ return safe_div_func_uint8_t_u_u (1, 8 & x);
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr44806.c b/gcc/testsuite/gcc.dg/torture/pr44806.c
new file mode 100644
index 000000000..8b67b10f5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr44806.c
@@ -0,0 +1,91 @@
+/* { dg-do run } */
+/* { dg-options "-std=c99" } */
+
+#include <stdint.h>
+
+extern void abort (void);
+
+#define N_DEV_BITS_4 5
+#define N_INO_BITS_4 (32 - N_DEV_BITS_4 - 2 - 1)
+
+#define N_DEV_BITS_8 8
+#define N_INO_BITS_8 (64 - N_DEV_BITS_8 - 2 - 1)
+
+struct dev_ino_4
+{
+ uint32_t mode:2;
+ uint32_t short_ino:N_INO_BITS_4;
+ uint32_t mapped_dev:N_DEV_BITS_4;
+ uint32_t always_set:1;
+};
+
+struct dev_ino_8
+{
+ uint32_t mode:2;
+ uint64_t short_ino:N_INO_BITS_8;
+ uint32_t mapped_dev:N_DEV_BITS_8;
+ uint32_t always_set:1;
+};
+
+struct dev_ino_full
+{
+ uint32_t mode:2;
+ uint32_t dev;
+ uint32_t ino;
+};
+
+enum di_mode
+{
+ DI_MODE_4 = 1,
+ DI_MODE_8 = 2,
+ DI_MODE_FULL = 3
+};
+
+struct di_ent
+{
+ union
+ {
+ struct dev_ino_4 di4;
+ struct dev_ino_8 di8;
+ struct dev_ino_full full;
+ uint32_t u32;
+ uint64_t u64;
+ void *ptr;
+ } u;
+};
+
+static struct di_ent
+decode_ptr (struct di_ent const *v)
+{
+ struct di_ent di;
+ di.u.ptr = (void *) v;
+ return di;
+}
+
+static int
+di_ent_equal (void const *x, void const *y)
+{
+ struct di_ent a = decode_ptr (x);
+ struct di_ent b = decode_ptr (y);
+ if (a.u.di4.mode != b.u.di4.mode)
+ return 0;
+
+ if (a.u.di4.mode == DI_MODE_4)
+ return (a.u.di4.short_ino == b.u.di4.short_ino
+ && a.u.di4.mapped_dev == b.u.di4.mapped_dev);
+
+ if (a.u.di8.mode == DI_MODE_8)
+ return (a.u.di8.short_ino == b.u.di8.short_ino
+ && a.u.di8.mapped_dev == b.u.di8.mapped_dev);
+
+ return (a.u.full.ino == b.u.full.ino
+ && a.u.full.dev == b.u.full.dev);
+}
+
+int
+main ()
+{
+ if (di_ent_equal ((void *) 0x80143c4d, (void *) 0x80173851) != 0)
+ abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr44807.c b/gcc/testsuite/gcc.dg/torture/pr44807.c
new file mode 100644
index 000000000..aa24a4c32
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr44807.c
@@ -0,0 +1,40 @@
+/* { dg-do compile } */
+
+struct jobstats
+{
+ int j_jobslots;
+};
+struct jobstats js;
+int *jobs;
+
+typedef int sh_job_map_func_t (int *, int, int, int);
+
+static void
+map_over_jobs (sh_job_map_func_t func)
+{
+ int i;
+ int set, oset;
+ if (js.j_jobslots)
+ return;
+ sigemptyset (&set);
+ sigaddset (set, 17);
+ sigemptyset (&oset);
+ sigprocmask (0, set, oset);
+ for (i = 0; js.j_jobslots; i++)
+ if (jobs[i])
+ func (jobs, 0, 0, 0);
+ sigprocmask (oset, ((void *) 0));
+}
+
+int
+print_job (int *job, int format, int state, int job_index)
+{
+ map_over_jobs (print_job);
+}
+
+void
+list_running_jobs (void)
+{
+ map_over_jobs (print_job);
+}
+
diff --git a/gcc/testsuite/gcc.dg/torture/pr44913.c b/gcc/testsuite/gcc.dg/torture/pr44913.c
new file mode 100644
index 000000000..eef61fbfb
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr44913.c
@@ -0,0 +1,24 @@
+/* { dg-do run } */
+
+void __attribute__((noinline,noclone))
+foo (int *a, int n)
+{
+ int *lasta = a + n;
+ for (; a != lasta; a++)
+ {
+ *a *= 2;
+ a[1] = a[-1] + a[-2];
+ }
+}
+extern void abort (void);
+int main()
+{
+ int a[16] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
+ int r[16] = { 1, 2, 6, 6, 16, 24, 44, 80, 136, 248, 432, 768, 1360, 2400, 4256, 3760 };
+ unsigned i;
+ foo (&a[2], 13);
+ for (i = 0; i < 8; ++i)
+ if (a[i] != r[i])
+ abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr44977.c b/gcc/testsuite/gcc.dg/torture/pr44977.c
new file mode 100644
index 000000000..66fd7d1bf
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr44977.c
@@ -0,0 +1,41 @@
+/* { dg-do compile } */
+/* { dg-options "-w" } */
+
+static unsigned short
+foo (unsigned short ui1, unsigned short ui2)
+{
+ return ui1 - ui2;
+}
+
+static unsigned short
+bar (unsigned ui1, unsigned short ui2)
+{
+ return ui1 + ui2;
+}
+
+struct S1
+{
+ const short f3;
+};
+int g_31;
+short g_67;
+struct S1 g_68[2][5][9][1][1] = {
+};
+
+int func_90 (int);
+
+int int329 (int * const *const int32p_81, short ** p_82)
+{
+ short l_169[8];
+ for (g_31 = 0; g_31 <= 0; g_31 = foo (g_31, 1))
+ {
+ short l_85;
+lbl_89:g_67 ^= l_85;
+ for (l_85 = 0; l_85 >= 0; l_85 = bar)
+ if (g_31)
+ goto lbl_89;
+ func_90 (1), g_68[0][2][2][0][0].f3, 0;
+ }
+ return l_169[6];
+}
+
diff --git a/gcc/testsuite/gcc.dg/torture/pr45017.c b/gcc/testsuite/gcc.dg/torture/pr45017.c
new file mode 100644
index 000000000..f2e02bcea
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr45017.c
@@ -0,0 +1,24 @@
+/* { dg-do run { target i?86-*-* x86_64-*-* } } */
+
+int tester(char *bytes)
+{
+ union {
+ struct {
+ unsigned int r1:4;
+ unsigned int r2:4;
+ } fmt;
+ char value[1];
+ } ovl;
+
+ ovl.value[0] = bytes[0];
+ return ovl.fmt.r1;
+}
+extern void abort (void);
+int main()
+{
+ char buff = 0x2f;
+ if (tester(&buff) != 0x0f)
+ abort ();
+ return 0;
+}
+
diff --git a/gcc/testsuite/gcc.dg/torture/pr45623.c b/gcc/testsuite/gcc.dg/torture/pr45623.c
new file mode 100644
index 000000000..693a8c4c7
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr45623.c
@@ -0,0 +1,29 @@
+/* { dg-do run } */
+/* { dg-options "-std=c99" } */
+
+#include <stdint.h>
+
+extern void abort (void);
+
+char *s1 = "foo";
+char *s2 = "bar";
+
+char **ss1 = &s1;
+
+typedef union jsval_layout
+{
+ uint64_t asBits;
+ char **ptr;
+} jsval_layout;
+
+int main()
+{
+ jsval_layout l, m;
+ l.ptr = ss1;
+ m.asBits = l.asBits;
+ char ** data = m.ptr;
+ *data = s2;
+ if (s1 != s2)
+ abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr45636.c b/gcc/testsuite/gcc.dg/torture/pr45636.c
new file mode 100644
index 000000000..0566de86e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr45636.c
@@ -0,0 +1,77 @@
+/* { dg-do run } */
+/* { dg-require-effective-target mempcpy } */
+/* PR fortran/45636 */
+
+typedef __SIZE_TYPE__ size_t;
+void *memcpy (void *__restrict__, const void *__restrict__, size_t);
+void *mempcpy (void *__restrict__, const void *__restrict__, size_t);
+void *memset (void *, int, size_t);
+int memcmp (const void *, const void *, size_t);
+extern void abort (void);
+
+struct A { int i; char c[32]; } a[2];
+
+__attribute__((noinline, noclone)) int
+f1 (char *p, int q, int z)
+{
+ memcpy (p, "abcd", 4);
+ if (q)
+ z = z + 123;
+ else
+ z *= 114;
+ memset (p + 4, ' ', 2);
+ return z;
+}
+
+__attribute__((noinline, noclone)) void
+f2 (void)
+{
+ char *p = mempcpy (&a[0].c[13], "123456", 4);
+ memset (p, '7', 3);
+}
+
+__attribute__((noinline, noclone)) void
+f3 (struct A *p)
+{
+ p++;
+ char *q = &p->c[10];
+ memcpy (q + 4, "__1234567" + 2, 7);
+ memset (&p->c[21], '9', 3);
+}
+
+__attribute__((noinline, noclone)) void
+f4 (void)
+{
+ memcpy (&a[0].c[10], "0123456789", 10);
+ memset (&a[0].c[13], ' ', 3);
+}
+
+__attribute__((noinline, noclone)) void
+check (const char *p, const char *str, size_t size)
+{
+ const char *q;
+ for (q = (const char *) &a; q < p; q++)
+ if (*q)
+ abort ();
+ if (memcmp (p, str, size) != 0)
+ abort ();
+ for (q = p + size; q < (const char *) (&a[0] + 2); q++)
+ if (*q)
+ abort ();
+ memset (&a, '\0', sizeof a);
+}
+
+int
+main (void)
+{
+ if (f1 (&a[0].c[7], 1, 2) != 125)
+ abort ();
+ check (&a[0].c[7], "abcd ", 6);
+ f2 ();
+ check (&a[0].c[13], "1234777", 7);
+ f3 (&a[0]);
+ check (&a[1].c[14], "1234567999", 10);
+ f4 ();
+ check (&a[0].c[10], "012 6789", 10);
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr45678-1.c b/gcc/testsuite/gcc.dg/torture/pr45678-1.c
new file mode 100644
index 000000000..7a90b0ba8
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr45678-1.c
@@ -0,0 +1,17 @@
+/* { dg-do run } */
+/* { dg-options "-fno-common" { target { { hppa*-*-hpux* } && { ! hppa*64*-*-* } } } } */
+
+typedef float V __attribute__ ((vector_size (16)));
+V g;
+float d[4] = { 4, 3, 2, 1 };
+
+int
+main ()
+{
+ V e;
+ __builtin_memcpy (&e, &d, sizeof (d));
+ V f = { 5, 15, 25, 35 };
+ e = e * f;
+ g = e;
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr45678-2.c b/gcc/testsuite/gcc.dg/torture/pr45678-2.c
new file mode 100644
index 000000000..df79de7b1
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr45678-2.c
@@ -0,0 +1,17 @@
+/* { dg-do run } */
+/* { dg-options "-fno-common" { target { { hppa*-*-hpux* } && { ! hppa*64*-*-* } } } } */
+
+typedef float V __attribute__ ((vector_size (16)));
+V g;
+
+int
+main ()
+{
+ float d[4] = { 4, 3, 2, 1 };
+ V e;
+ __builtin_memcpy (&e, &d, sizeof (d));
+ V f = { 5, 15, 25, 35 };
+ e = e * f;
+ g = e;
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr45704.c b/gcc/testsuite/gcc.dg/torture/pr45704.c
new file mode 100644
index 000000000..487b30a96
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr45704.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-fdump-tree-optimized" } */
+
+struct st {
+ int ptr;
+};
+
+int foo(struct st *st)
+{
+ int v = *(volatile int *)&st->ptr;
+ return v & 0xff;
+}
+
+/* { dg-final { scan-tree-dump-times "={v}" 1 "optimized" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
diff --git a/gcc/testsuite/gcc.dg/torture/pr45720.c b/gcc/testsuite/gcc.dg/torture/pr45720.c
new file mode 100644
index 000000000..9de8d1117
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr45720.c
@@ -0,0 +1,50 @@
+/* { dg-do run } */
+/* { dg-options "-ftree-vectorize" } */
+
+float val[256];
+float x;
+void __attribute__((noinline,noclone))
+foo(int len, int beg)
+{
+ int i;
+ for (i = len - 1; i >= beg; --i)
+ x += val[i] * 2;
+}
+void __attribute__((noinline,noclone))
+bar(void)
+{
+ int i;
+ for (i = 255; i >= 0; --i)
+ x += val[i] * 2;
+ for (i = 254; i >= 0; --i)
+ x += val[i] * 2;
+ for (i = 253; i >= 0; --i)
+ x += val[i] * 2;
+ for (i = 252; i >= 0; --i)
+ x += val[i] * 2;
+}
+float y[256];
+void __attribute__((noinline,noclone))
+foobar(void)
+{
+ int i;
+ for (i = 0; i < 252; ++i)
+ {
+ float l = 0;
+ l += val[255 - i] * 2;
+ l += val[254 - i] * 2;
+ l += val[253 - i] * 2;
+ l += val[252 - i] * 2;
+ y[i] = l;
+ }
+}
+int main()
+{
+ foo(256-1, 0);
+ foo(256-2, 0);
+ foo(256-3, 0);
+ foo(256-4, 0);
+ bar();
+ foobar();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr45732.c b/gcc/testsuite/gcc.dg/torture/pr45732.c
new file mode 100644
index 000000000..04ceaa279
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr45732.c
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+
+typedef char chars[5];
+const chars bad_chars[] = { "" };
+
+int foo ()
+{
+ const chars *c = bad_chars;
+ return c[0][0];
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr45764.c b/gcc/testsuite/gcc.dg/torture/pr45764.c
new file mode 100644
index 000000000..6d43b8725
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr45764.c
@@ -0,0 +1,27 @@
+/* { dg-do run } */
+
+int result[64][16];
+
+int main()
+{
+ double dbuf[1000] = {0.0};
+ int ibuf[900];
+ int i, j;
+
+ double d1 = 0.0;
+ double d2 = 0.0;
+ for (i = 0; i < 900; ++i) {
+ ibuf[i] = (int)(d2 - d1);
+ d1 += dbuf[i];
+ d2 += dbuf[i + 64];
+ }
+
+ for (i = 0; i < 64; ++i) {
+ for (j = 0; j < 8; ++j) {
+ result[i][ j] = ibuf[64 - i + 64 * j];
+ result[i][15 - j] = ibuf[ i + 64 * j];
+ }
+ }
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr45860.c b/gcc/testsuite/gcc.dg/torture/pr45860.c
new file mode 100644
index 000000000..4a48bc559
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr45860.c
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+
+void
+foo (char *str, int i)
+{
+ static const char text[] = "";
+ str[i] = 0;
+ if (i & 1)
+ __builtin_strcpy (str + i, text);
+}
+
diff --git a/gcc/testsuite/gcc.dg/torture/pr45865.c b/gcc/testsuite/gcc.dg/torture/pr45865.c
new file mode 100644
index 000000000..f2e31dbab
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr45865.c
@@ -0,0 +1,54 @@
+/* { dg-do compile } */
+
+typedef struct rtx_def *rtx;
+enum machine_mode {
+ VOIDmode,
+ CCFPmode,
+ CCFPUmode,
+ MAX_MACHINE_MODE
+};
+enum mode_class {
+ MODE_CC,
+ MODE_FLOAT,
+ MODE_COMPLEX_FLOAT,
+ MODE_VECTOR_FLOAT
+};
+extern const enum mode_class mode_class[(int) MAX_MACHINE_MODE];
+enum rtx_code {
+ UNKNOWN,
+ GEU,
+ ORDERED,
+ CONST_INT
+};
+struct rtx_def {
+ unsigned int code: 16;
+ unsigned int mode : 8;
+};
+extern enum rtx_code reverse_condition (enum rtx_code);
+enum rtx_code
+reversed_comparison_code_parts (enum rtx_code code, rtx insn, rtx arg0,
+ rtx arg1)
+{
+ enum machine_mode mode;
+ mode = (enum machine_mode) (arg0)->mode;
+ if (mode == VOIDmode)
+ mode = (enum machine_mode) (arg1)->mode;
+ if ((mode_class[(int) (mode)]) == MODE_CC)
+ return (mode != CCFPmode && mode != CCFPUmode
+ ? reverse_condition (code)
+ : reverse_condition_maybe_unordered (code));
+ switch (code)
+ {
+ case GEU:
+ return reverse_condition (code);
+ case ORDERED:
+ return UNKNOWN;
+ }
+ if (((enum rtx_code) (arg0)->code) == CONST_INT
+ || (((enum machine_mode) (arg0)->mode) != VOIDmode
+ && ! ((mode_class[(int) (mode)]) == MODE_FLOAT
+ || (mode_class[(int) (mode)]) == MODE_COMPLEX_FLOAT
+ || (mode_class[(int) (mode)]) == MODE_VECTOR_FLOAT)))
+ return reverse_condition (code);
+ return UNKNOWN;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr45869.c b/gcc/testsuite/gcc.dg/torture/pr45869.c
new file mode 100644
index 000000000..e01977bf9
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr45869.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+
+char *
+foo (unsigned int count, void **list)
+{
+ char *minaddr = (char *) list[0];
+ unsigned int i; /* NOTE: change of type to "int" eliminates the ICE */
+ for (i = 1; i < count; i++)
+ {
+ char *addr = (char *) list[i];
+ if (addr < minaddr)
+ minaddr = addr;
+ }
+ return minaddr;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr45967-2.c b/gcc/testsuite/gcc.dg/torture/pr45967-2.c
new file mode 100644
index 000000000..6959fd5e1
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr45967-2.c
@@ -0,0 +1,24 @@
+/* { dg-do run } */
+
+extern void abort (void);
+int b;
+void
+foo (void *p_, int *q)
+{
+ int *p;
+ int i;
+ for (i = 0; i < sizeof(int *); ++i)
+ ((char *)&p)[i] = ((char *)p_)[i];
+ if (b)
+ p = q;
+ *p = 1;
+}
+int main()
+{
+ int i = 0, j;
+ int *p = &i;
+ foo (&p, &j);
+ if (i != 1)
+ abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr45967-3.c b/gcc/testsuite/gcc.dg/torture/pr45967-3.c
new file mode 100644
index 000000000..1a23a773b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr45967-3.c
@@ -0,0 +1,21 @@
+/* { dg-do run } */
+
+extern void abort (void);
+void
+foo (void *p_)
+{
+ int *p;
+ int i;
+ for (i = 0; i < sizeof(int *); ++i)
+ ((char *)&p)[i] = ((char *)p_)[i];
+ *p = 1;
+}
+int main()
+{
+ int i = 0;
+ int *p = &i;
+ foo (&p);
+ if (i != 1)
+ abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr45967.c b/gcc/testsuite/gcc.dg/torture/pr45967.c
new file mode 100644
index 000000000..0a5b206e5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr45967.c
@@ -0,0 +1,21 @@
+/* { dg-do run } */
+
+extern void abort (void);
+void __attribute__((noinline,noclone))
+foo (void *p_)
+{
+ int *p;
+ int i;
+ for (i = 0; i < sizeof(int *); ++i)
+ ((char *)&p)[i] = ((char *)p_)[i];
+ *p = 1;
+}
+int main()
+{
+ int i = 0;
+ int *p = &i;
+ foo (&p);
+ if (i != 1)
+ abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr45982.c b/gcc/testsuite/gcc.dg/torture/pr45982.c
new file mode 100644
index 000000000..4aea6a8d8
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr45982.c
@@ -0,0 +1,28 @@
+/* { dg-do run } */
+/* { dg-options "-std=c99" } */
+
+#include <stdint.h>
+
+extern void abort (void);
+
+uintptr_t __attribute__((pure,noinline,noclone))
+foo (int *a)
+{
+ return (uintptr_t) a;
+}
+
+void __attribute__((noinline,noclone))
+bar (uintptr_t a)
+{
+ int *p = (int *)a;
+ *p = 1;
+}
+
+int main()
+{
+ int t = 0;
+ bar (foo (&t));
+ if (t != 1)
+ abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr46068.c b/gcc/testsuite/gcc.dg/torture/pr46068.c
new file mode 100644
index 000000000..120119ce8
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr46068.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+void
+foo ()
+{
+ asm goto (""::::l1);
+ __builtin_unreachable ();
+l1:;
+}
+
+void
+bar ()
+{
+ foo ();
+ foo ();
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr46172.c b/gcc/testsuite/gcc.dg/torture/pr46172.c
new file mode 100644
index 000000000..c8d1b4759
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr46172.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-fno-tree-dce -ftree-vectorize" } */
+
+extern short X[];
+
+int foo (int len)
+{
+ int i;
+ int s = 0;
+ for (i = 0; i < len; i++)
+ s += X[i] * X[i];
+ return s;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr46183.c b/gcc/testsuite/gcc.dg/torture/pr46183.c
new file mode 100644
index 000000000..9582c34e0
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr46183.c
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+/* { dg-options "-fno-dse" } */
+
+void bar(void);
+
+void foo (int i, ...)
+{
+ __builtin_va_list ap;
+ __builtin_va_start (ap, i);
+ __builtin_va_arg (ap, int);
+ while (i) i++;
+ __builtin_va_arg (ap, int);
+ while (i) i++;
+ __builtin_va_arg (ap, int);
+ while (i) i++;
+ __builtin_va_arg (ap, int);
+ if (i)
+ bar ();
+}
+
diff --git a/gcc/testsuite/gcc.dg/torture/pr46216.c b/gcc/testsuite/gcc.dg/torture/pr46216.c
new file mode 100644
index 000000000..b257dbf2c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr46216.c
@@ -0,0 +1,24 @@
+/* { dg-do compile } */
+
+typedef int Embryo_Cell;
+int
+embryo_program_run(Embryo_Cell *cip)
+{
+ unsigned char op;
+ Embryo_Cell offs;
+ static const void *switchtable[256] = {
+ &&SWITCHTABLE_EMBRYO_OP_NONE, &&SWITCHTABLE_EMBRYO_OP_LOAD_PRI
+ };
+ for (;;)
+ {
+ op = *cip++;
+ while (1) {
+ goto *switchtable[op];
+SWITCHTABLE_EMBRYO_OP_LOAD_PRI:
+ offs = *(Embryo_Cell *)cip++;
+SWITCHTABLE_EMBRYO_OP_NONE:
+ break;
+ };
+ }
+ return offs;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr46398.c b/gcc/testsuite/gcc.dg/torture/pr46398.c
new file mode 100644
index 000000000..9110bbbbe
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr46398.c
@@ -0,0 +1,24 @@
+/* { dg-do run } */
+
+int __attribute__((noinline))
+test (int token)
+{
+ int done = 0;
+ int virtual_p = 0;
+ while (!done)
+ {
+ if (token == 42)
+ virtual_p = 1;
+ else
+ done = 1;
+ }
+ return virtual_p;
+}
+extern void abort (void);
+int
+main()
+{
+ if (test (0) != 0)
+ abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr46723.c b/gcc/testsuite/gcc.dg/torture/pr46723.c
new file mode 100644
index 000000000..40c6e8cd6
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr46723.c
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+
+short *m;
+void test()
+{
+ short x = 128;
+ unsigned int i;
+ for (i = 0; i < 128; ++i, x = (unsigned short)x + 1)
+ m[i] = x;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr47228.c b/gcc/testsuite/gcc.dg/torture/pr47228.c
new file mode 100644
index 000000000..5bc9f0ad5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr47228.c
@@ -0,0 +1,31 @@
+/* { dg-do run } */
+
+struct S4
+{
+ unsigned f0:24;
+} __attribute__((__packed__));
+
+struct S4 g_10 = {
+ 6210831
+};
+
+struct S4 func_2 (int x)
+{
+ struct S4 l_8[2] = {
+ {0}, {0}
+ };
+ g_10 = l_8[1];
+ for (; x<2; x++) {
+ struct S4 tmp = {
+ 11936567
+ };
+ l_8[x] = tmp;
+ }
+ return g_10;
+}
+
+int main (void)
+{
+ func_2 (0);
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr47278-1.c b/gcc/testsuite/gcc.dg/torture/pr47278-1.c
new file mode 100644
index 000000000..f97906c61
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr47278-1.c
@@ -0,0 +1,5 @@
+/* { dg-do run } */
+/* { dg-require-visibility "" } */
+/* { dg-additional-sources "pr47278-2.c" } */
+
+int foo (void) { return 1; }
diff --git a/gcc/testsuite/gcc.dg/torture/pr47278-2.c b/gcc/testsuite/gcc.dg/torture/pr47278-2.c
new file mode 100644
index 000000000..0c700d196
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr47278-2.c
@@ -0,0 +1,15 @@
+/* { dg-require-visibility "" } */
+
+extern void abort (void);
+
+int __attribute__((weak,visibility("hidden"))) foo (void)
+{
+ return 0;
+}
+
+int main()
+{
+ if (foo() != 1)
+ abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr47281.c b/gcc/testsuite/gcc.dg/torture/pr47281.c
new file mode 100644
index 000000000..517e8548e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr47281.c
@@ -0,0 +1,23 @@
+/* { dg-do compile } */
+
+struct T;
+typedef void F(void);
+
+F* aux(void (*x)())
+{
+ return x;
+}
+
+void make_mess (int);
+
+F*
+get_funloc (void (*x)(int), F* (*y)())
+{
+ return y(x);
+}
+
+F*
+foo ()
+{
+ return get_funloc (make_mess, aux);
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr47365.c b/gcc/testsuite/gcc.dg/torture/pr47365.c
new file mode 100644
index 000000000..e3bc55011
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr47365.c
@@ -0,0 +1,39 @@
+/* { dg-do run } */
+
+struct A
+{
+ int i;
+};
+
+struct B
+{
+ struct A a[2];
+};
+
+int i = 1;
+struct B b = { 0, 3 };
+
+static void
+test ()
+{
+ if (b.a[0].i != i)
+ {
+ int t = b.a[0].i;
+ b.a[0] = b.a[1];
+ b.a[1].i = t;
+ }
+
+ if (b.a[1].i == i)
+ __builtin_abort ();
+
+ if (b.a[0].i == 0)
+ __builtin_abort ();
+}
+
+int
+main ()
+{
+ test ();
+ return 0;
+}
+
diff --git a/gcc/testsuite/gcc.dg/torture/pr47370.c b/gcc/testsuite/gcc.dg/torture/pr47370.c
new file mode 100644
index 000000000..ff71f0964
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr47370.c
@@ -0,0 +1,27 @@
+/* { dg-do compile } */
+
+struct S { int s; };
+
+void
+foo (void)
+{
+ for (;;)
+ ;
+}
+
+struct S
+bar (void)
+{
+ struct S s = { 99 };
+ return s;
+}
+
+void
+baz (int i)
+{
+ struct S s[1];
+ s[0] = bar ();
+ bar ();
+ foo ();
+}
+
diff --git a/gcc/testsuite/gcc.dg/torture/pr47411.c b/gcc/testsuite/gcc.dg/torture/pr47411.c
new file mode 100644
index 000000000..d3c10d331
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr47411.c
@@ -0,0 +1,42 @@
+/* { dg-do compile } */
+
+typedef long unsigned int size_t;
+
+static __inline void *
+__inline_memcpy_chk (void *__dest, const void *__src, size_t __len)
+{
+ return __builtin___memcpy_chk (__dest, __src, __len, __builtin_object_size (__dest, 0));
+}
+
+extern void *xmalloc (size_t) __attribute__ ((__malloc__));
+
+struct htab { void ** entries; };
+
+typedef struct htab *htab_t;
+
+extern void ** htab_find_slot (htab_t, const void *);
+
+enum mode_class { MODE_RANDOM, MODE_CC, MODE_INT, MAX_MODE_CLASS };
+
+struct mode_data
+{
+ struct mode_data *next;
+ enum mode_class cl;
+};
+
+static const struct mode_data blank_mode = { 0, MAX_MODE_CLASS };
+
+static htab_t modes_by_name;
+
+struct mode_data *
+new_mode (void)
+{
+ struct mode_data *m
+ = ((struct mode_data *) xmalloc (sizeof (struct mode_data)));
+
+ ((__builtin_object_size (m, 0) != (size_t) -1) ? __builtin___memcpy_chk (m, &blank_mode, sizeof (struct mode_data), __builtin_object_size (m, 0)) : __inline_memcpy_chk (m, &blank_mode, sizeof (struct mode_data)));
+
+ *htab_find_slot (modes_by_name, m) = m;
+
+ return m;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr47426-1.c b/gcc/testsuite/gcc.dg/torture/pr47426-1.c
new file mode 100644
index 000000000..47dcff913
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr47426-1.c
@@ -0,0 +1,23 @@
+/* { dg-do run } */
+/* { dg-options "-fipa-pta" } */
+/* { dg-additional-sources "pr47426-2.c" } */
+
+void bar (int *i);
+
+static void
+foo (int *i)
+{
+ if (*i)
+ bar (i);
+ if (*i)
+ __builtin_abort();
+}
+
+typedef void tfoo (int *);
+
+tfoo *
+getfoo (void)
+{
+ return &foo;
+}
+
diff --git a/gcc/testsuite/gcc.dg/torture/pr47426-2.c b/gcc/testsuite/gcc.dg/torture/pr47426-2.c
new file mode 100644
index 000000000..a22e902bc
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr47426-2.c
@@ -0,0 +1,19 @@
+typedef void tfoo (int *);
+tfoo *getfoo (void);
+
+void
+bar (int *i)
+{
+ (*i)--;
+}
+
+int
+main ()
+{
+ int i = 1;
+ getfoo ()(&i);
+ if (i)
+ __builtin_abort ();
+ return 0;
+}
+
diff --git a/gcc/testsuite/gcc.dg/torture/pr47473.c b/gcc/testsuite/gcc.dg/torture/pr47473.c
new file mode 100644
index 000000000..92f2b872e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr47473.c
@@ -0,0 +1,14 @@
+/* PR c/47473 */
+/* { dg-do run } */
+/* { dg-options "-std=c99" } */
+
+int
+main (void)
+{
+ long double _Complex w = 0.2L - 0.3iL;
+ w = w * (0.3L - (0.0F + 1.0iF) * 0.9L);
+ if (__builtin_fabsl (__real__ w + 0.21L) > 0.001L
+ || __builtin_fabsl (__imag__ w + 0.27L) > 0.001L)
+ __builtin_abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr47621.c b/gcc/testsuite/gcc.dg/torture/pr47621.c
new file mode 100644
index 000000000..882e67f08
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr47621.c
@@ -0,0 +1,14 @@
+/* { dg-do run } */
+
+extern void abort (void);
+
+int
+main (void)
+{
+ int data = 1;
+ struct ptr { int val; } *ptr = (struct ptr *) &data;
+ ptr->val = 0;
+ if (data != 0)
+ abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr47677.c b/gcc/testsuite/gcc.dg/torture/pr47677.c
new file mode 100644
index 000000000..bd9077863
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr47677.c
@@ -0,0 +1,34 @@
+/* { dg-do compile } */
+
+struct S { int s; int u; };
+extern int bar (void);
+extern struct S *baz (void);
+
+void
+foo (int x, struct S *y, char z, int *v, struct S *s)
+{
+ int c, d;
+ if (x & 2)
+ d = 1;
+ else
+ {
+ d = (x & 1) ? 11 : 0;
+ while ((c = (s->s != (s->u & 1) ? s->s : bar ())) != '\0');
+ c = (s->s != '\\' && (s->u & 4) ? s->s : bar ());
+ if (c == '<')
+ goto lab;
+ }
+ while ((c = ((s->u & 1) ? s->s : bar ())) != 0
+ && ((d != 11 && d != 17) || (v[c] & 1) == 0))
+ {
+ lab:;
+ switch (d)
+ {
+ case 14:
+ if (c == '}')
+ y = baz ();
+ d = y->s = z == '<' ? 17 : 11;
+ }
+ }
+}
+
diff --git a/gcc/testsuite/gcc.dg/torture/pr47743.c b/gcc/testsuite/gcc.dg/torture/pr47743.c
new file mode 100644
index 000000000..1930e94d2
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr47743.c
@@ -0,0 +1,22 @@
+/* { dg-do compile } */
+
+int
+foo (void *x, int y)
+{
+ long long a = 1, *b;
+ double *c;
+ if (y)
+ {
+ b = (long long *) x;
+ while (b)
+ a *= *b++;
+ }
+ else
+ {
+ c = (double *) x;
+ while (c)
+ a *= *c++;
+ }
+ return a;
+}
+
diff --git a/gcc/testsuite/gcc.dg/torture/pr47890.c b/gcc/testsuite/gcc.dg/torture/pr47890.c
new file mode 100644
index 000000000..83cb5e6d9
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr47890.c
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+
+void f(char *s)
+{
+ signed short i;
+
+ for (i = 0; i < 19; i = i + 1)
+ s[i] = i;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr47968.c b/gcc/testsuite/gcc.dg/torture/pr47968.c
new file mode 100644
index 000000000..4f33cf1f3
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr47968.c
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options "-w -Wno-psabi" } */
+
+typedef __attribute__ ((vector_size (16))) float float4;
+typedef __attribute__ ((vector_size (16))) double double2;
+
+float foo (double2 d2)
+{
+ float4 f4 = (float4) d2;
+ return *(float *) &f4;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr47975.c b/gcc/testsuite/gcc.dg/torture/pr47975.c
new file mode 100644
index 000000000..e2a72af49
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr47975.c
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options "-fno-common" { target { hppa*-*-hpux* } } } */
+
+int __attribute__ ((vector_size (32))) x;
+
+void
+foo (void)
+{
+ x <<= x;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr48044.c b/gcc/testsuite/gcc.dg/torture/pr48044.c
new file mode 100644
index 000000000..fe3b73402
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr48044.c
@@ -0,0 +1,7 @@
+/* PR middle-end/48044 */
+/* { dg-do compile } */
+/* { dg-require-alias "" } */
+
+int a __asm__ ("b") = 0;
+extern int c __asm__ ("a") __attribute__ ((alias ("b")));
+extern int d __attribute__ ((weak, alias ("a")));
diff --git a/gcc/testsuite/gcc.dg/torture/pr48063.c b/gcc/testsuite/gcc.dg/torture/pr48063.c
new file mode 100644
index 000000000..d861bf04c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr48063.c
@@ -0,0 +1,19 @@
+/* PR tree-optimization/48063 */
+/* { dg-do compile } */
+/* { dg-options "-fno-early-inlining" } */
+
+extern void abort (void);
+static void bar ();
+
+void
+foo ()
+{
+ bar (1);
+}
+
+static void
+bar (double i)
+{
+ if (i)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr48098.c b/gcc/testsuite/gcc.dg/torture/pr48098.c
new file mode 100644
index 000000000..cd7293937
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr48098.c
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+
+void
+foo (int n)
+{
+ static char *__restrict *p;
+ int i;
+ p = __builtin_malloc (n);
+ for (i = 0; i < n; i++)
+ p[i] = 0;
+}
+
diff --git a/gcc/testsuite/gcc.dg/torture/pr48343.c b/gcc/testsuite/gcc.dg/torture/pr48343.c
new file mode 100644
index 000000000..e56b3a3da
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr48343.c
@@ -0,0 +1,19 @@
+/* PR debug/48343 */
+/* { dg-do compile } */
+/* { dg-options "-fcompare-debug" } */
+
+void foo (unsigned char *, unsigned char *);
+
+void
+test (unsigned int x, int y)
+{
+ unsigned int i, j = 0, k;
+ unsigned char s[256], t[64];
+ foo (s, t);
+ t[0] = y;
+ for (i = 0; i < 256; i++)
+ {
+ j = (j + s[i] + t[i % x]) & 0xff;
+ k = i; i = j; j = k;
+ }
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr48542.c b/gcc/testsuite/gcc.dg/torture/pr48542.c
new file mode 100644
index 000000000..e3e49489f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr48542.c
@@ -0,0 +1,57 @@
+/* { dg-do run } */
+/* The return-address was clobbered. */
+#include <stdlib.h>
+#include <setjmp.h>
+
+jmp_buf env;
+extern void sub(void);
+extern void sub3(void);
+int called;
+__attribute__ ((__noinline__))
+int sjtest()
+{
+ int i;
+ if (setjmp(env))
+ return 99;
+
+ for (i = 0; i < 10; i++)
+ sub();
+
+ longjmp(env, 1);
+}
+
+__attribute__ ((__noinline__))
+void sub(void)
+{
+ called++;
+}
+
+int called3;
+__attribute__ ((__noinline__))
+int sjtest3()
+{
+ int i;
+ if (setjmp(env))
+ return 42;
+
+ for (i = 0; i < 10; i++)
+ sub3();
+ return 0;
+}
+
+__attribute__ ((__noinline__))
+void sub3(void)
+{
+ called3++;
+ if (called3 == 10)
+ longjmp (env, 1);
+}
+
+int main(void)
+{
+ if (sjtest() != 99 || called != 10)
+ abort();
+ if (sjtest3() != 42 || called3 != 10)
+ abort();
+ exit (0);
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr48702.c b/gcc/testsuite/gcc.dg/torture/pr48702.c
new file mode 100644
index 000000000..1ec371da8
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr48702.c
@@ -0,0 +1,47 @@
+/* { dg-do run } */
+
+extern void abort (void);
+
+#define LEN 4
+
+static inline void unpack(int array[LEN])
+{
+ int ii, val;
+ val = 1;
+ for (ii = 0; ii < LEN; ii++) {
+ array[ii] = val % 2;
+ val = val / 2;
+ }
+}
+
+static inline int pack(int array[LEN])
+{
+ int ans, ii;
+ ans = 0;
+ for (ii = LEN-1; ii >= 0; ii--) {
+ ans = 2 * ans + array[ii];
+ }
+ return ans;
+}
+
+int __attribute__((noinline))
+foo()
+{
+ int temp, ans;
+ int array[LEN];
+ unpack(array);
+ temp = array[0];
+ array[0] = array[2];
+ array[2] = temp;
+ ans = pack(array);
+ return ans;
+}
+
+int main(void)
+{
+ int val;
+ val = foo();
+ if (val != 4)
+ abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr48731.c b/gcc/testsuite/gcc.dg/torture/pr48731.c
new file mode 100644
index 000000000..74b77f67c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr48731.c
@@ -0,0 +1,24 @@
+/* { dg-do compile } */
+
+#include <stdarg.h>
+
+int blah(int a, ...)
+{
+ va_list va;
+ va_start(va,a);
+ if (a == 0)
+ return -1;
+ else
+ {
+ int i;
+ for (i = 0; i < a; i++)
+ va_arg(va,int);
+ return va_arg(va,int);
+ }
+}
+
+__attribute((flatten))
+int blah2(int b, int c)
+{
+ return blah(2, b, c);
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr48822.c b/gcc/testsuite/gcc.dg/torture/pr48822.c
new file mode 100644
index 000000000..b619f369b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr48822.c
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+
+void foo (int *, int *);
+int bar ()
+{
+ int a = 0;
+ int b = 0;
+ if (b != 0)
+ {
+ int ax = a;
+ int bx = b;
+ while (bx != 0)
+ {
+ int tem = ax % bx;
+ ax = bx;
+ bx = tem;
+ }
+ }
+ foo (&a, &b);
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr48953.c b/gcc/testsuite/gcc.dg/torture/pr48953.c
new file mode 100644
index 000000000..41a3d7b80
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr48953.c
@@ -0,0 +1,17 @@
+/* { dg-do run } */
+/* { dg-options "-fno-tree-dce" } */
+
+static inline int foo (int n, int k)
+{
+ struct S
+ {
+ int i[n];
+ int value;
+ } s[2];
+ return s[k].value = 0;
+}
+
+int main ()
+{
+ return foo (2, 0);
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr49079.c b/gcc/testsuite/gcc.dg/torture/pr49079.c
new file mode 100644
index 000000000..1b53d3c31
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr49079.c
@@ -0,0 +1,31 @@
+/* { dg-do run } */
+
+extern void abort (void);
+
+struct Ustr
+{
+ unsigned char data[1];
+};
+
+static unsigned int
+ustr_xi__embed_val_get(const unsigned char *data)
+{
+ return (unsigned int)data[0];
+}
+
+int __attribute__((noinline)) zero(void) { return 0; }
+
+static unsigned int
+ustr_len(const struct Ustr *s1)
+{
+ return ustr_xi__embed_val_get(s1->data + 1 + zero());
+}
+
+int
+main()
+{
+ if (ustr_len (((struct Ustr *) "\x01" "\x0002" "s2")) != 2)
+ abort ();
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr49217.c b/gcc/testsuite/gcc.dg/torture/pr49217.c
new file mode 100644
index 000000000..e8a89de8f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr49217.c
@@ -0,0 +1,26 @@
+/* { dg-do run } */
+/* { dg-options "-fno-early-inlining" } */
+
+extern void abort (void);
+int i;
+static void foo(void);
+void __attribute__((noinline))
+bar (void)
+{
+ if (!i)
+ foo ();
+}
+static void
+foo(void)
+{
+ i = 1;
+ bar ();
+}
+int main()
+{
+ i = 0;
+ bar();
+ if (i != 1)
+ abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr49518.c b/gcc/testsuite/gcc.dg/torture/pr49518.c
new file mode 100644
index 000000000..84a10fbbe
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr49518.c
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+
+int a, b;
+struct S { unsigned int s, t, u; } c, d = { 0, 1, 0 };
+
+void
+test (unsigned char z)
+{
+ char e[] = {0, 0, 0, 0, 1};
+ for (c.s = 1; c.s; c.s++)
+ {
+ b = e[c.s];
+ if (a)
+ break;
+ b = z >= c.u;
+ if (d.t)
+ break;
+ }
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr49651.c b/gcc/testsuite/gcc.dg/torture/pr49651.c
new file mode 100644
index 000000000..c58fe943c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr49651.c
@@ -0,0 +1,31 @@
+/* { dg-do run } */
+
+extern void abort (void);
+
+struct X {
+ int *p;
+ int *q;
+};
+
+void __attribute__((noinline, noclone))
+foo (struct X x) { *x.q = 0; }
+
+volatile int what;
+struct X y;
+
+int main()
+{
+ int i, j;
+ struct X x, *p;
+ x.p = &i;
+ x.q = &j;
+ if (what)
+ p = &y;
+ else
+ p = &x;
+ j = 1;
+ foo (*p);
+ if (j != 0)
+ abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr49886.c b/gcc/testsuite/gcc.dg/torture/pr49886.c
new file mode 100644
index 000000000..f0e8e60d3
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr49886.c
@@ -0,0 +1,102 @@
+/* { dg-do run } */
+
+struct PMC {
+ unsigned flags;
+};
+
+typedef struct Pcc_cell
+{
+ struct PMC *p;
+ long bla;
+ long type;
+} Pcc_cell;
+
+int gi;
+int cond;
+
+extern void abort ();
+extern void never_ever(int interp, struct PMC *pmc)
+ __attribute__((noinline,noclone));
+
+void never_ever (int interp, struct PMC *pmc)
+{
+ abort ();
+}
+
+static void mark_cell(int * interp, Pcc_cell *c)
+ __attribute__((__nonnull__(1)));
+
+static void
+mark_cell(int * interp, Pcc_cell *c)
+{
+ if (!cond)
+ return;
+
+ if (c && c->type == 4 && c->p
+ && !(c->p->flags & (1<<18)))
+ never_ever(gi + 1, c->p);
+ if (c && c->type == 4 && c->p
+ && !(c->p->flags & (1<<17)))
+ never_ever(gi + 2, c->p);
+ if (c && c->type == 4 && c->p
+ && !(c->p->flags & (1<<16)))
+ never_ever(gi + 3, c->p);
+ if (c && c->type == 4 && c->p
+ && !(c->p->flags & (1<<15)))
+ never_ever(gi + 4, c->p);
+ if (c && c->type == 4 && c->p
+ && !(c->p->flags & (1<<14)))
+ never_ever(gi + 5, c->p);
+ if (c && c->type == 4 && c->p
+ && !(c->p->flags & (1<<13)))
+ never_ever(gi + 6, c->p);
+ if (c && c->type == 4 && c->p
+ && !(c->p->flags & (1<<12)))
+ never_ever(gi + 7, c->p);
+ if (c && c->type == 4 && c->p
+ && !(c->p->flags & (1<<11)))
+ never_ever(gi + 8, c->p);
+ if (c && c->type == 4 && c->p
+ && !(c->p->flags & (1<<10)))
+ never_ever(gi + 9, c->p);
+}
+
+static void
+foo(int * interp, Pcc_cell *c)
+{
+ mark_cell(interp, c);
+}
+
+static struct Pcc_cell *
+__attribute__((noinline,noclone))
+getnull(void)
+{
+ return (struct Pcc_cell *) 0;
+}
+
+
+int main()
+{
+ int i;
+
+ cond = 1;
+ for (i = 0; i < 100; i++)
+ foo (&gi, getnull ());
+ return 0;
+}
+
+
+void
+bar_1 (int * interp, Pcc_cell *c)
+{
+ c->bla += 1;
+ mark_cell(interp, c);
+}
+
+void
+bar_2 (int * interp, Pcc_cell *c)
+{
+ c->bla += 2;
+ mark_cell(interp, c);
+}
+
diff --git a/gcc/testsuite/gcc.dg/torture/pr50092.c b/gcc/testsuite/gcc.dg/torture/pr50092.c
new file mode 100644
index 000000000..c8a929b2c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr50092.c
@@ -0,0 +1,15 @@
+/* PR target/50092 */
+/* { dg-do compile { target lp64 } } */
+
+volatile int v;
+
+void bar (long double);
+void baz (_Complex long double *);
+
+void
+foo (void)
+{
+ _Complex long double w[100000000];
+ bar ((long double) v / 2147483648.0);
+ baz (w);
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr50287.c b/gcc/testsuite/gcc.dg/torture/pr50287.c
new file mode 100644
index 000000000..1f61293a5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr50287.c
@@ -0,0 +1,109 @@
+/* { dg-do compile } */
+
+struct PMC {
+ unsigned flags;
+};
+
+struct PVC {
+ unsigned flags, other_stuff;
+};
+
+
+typedef struct Pcc_cell
+{
+ struct PMC *p;
+ long bla;
+ long type;
+} Pcc_cell;
+
+int gi;
+int cond;
+
+struct PVC g_pvc;
+
+extern void abort ();
+extern void never_ever(int interp, struct PMC *pmc)
+ __attribute__((noinline,noclone));
+
+void never_ever (int interp, struct PMC *pmc)
+{
+ abort ();
+}
+
+static void mark_cell(int * interp, Pcc_cell *c, struct PVC pvc)
+ __attribute__((__nonnull__(1)));
+
+static void
+mark_cell(int * interp, Pcc_cell *c, struct PVC pvc)
+{
+ if (!cond)
+ return;
+
+ if (c && c->type == 4 && c->p
+ && !(c->p->flags & (1<<8)))
+ never_ever(gi + 1, c->p);
+ if (c && c->type == 4 && c->p
+ && !(c->p->flags & (1<<7)))
+ never_ever(gi + 2, c->p);
+ if (c && c->type == 4 && c->p
+ && !(c->p->flags & (1<<6)))
+ never_ever(gi + 3, c->p);
+ if (c && c->type == 4 && c->p
+ && !(c->p->flags & (1<<5)))
+ never_ever(gi + 4, c->p);
+ if (c && c->type == 4 && c->p
+ && !(c->p->flags & (1<<4)))
+ never_ever(gi + 5, c->p);
+ if (c && c->type == 4 && c->p
+ && !(c->p->flags & (1<<3)))
+ never_ever(gi + 6, c->p);
+ if (c && c->type == 4 && c->p
+ && !(c->p->flags & (1<<2)))
+ never_ever(gi + 7, c->p);
+ if (c && c->type == 4 && c->p
+ && !(c->p->flags & (1<<1)))
+ never_ever(gi + 8, c->p);
+ if (c && c->type == 4 && c->p
+ && !(c->p->flags & (1<<9)))
+ never_ever(gi + 9, c->p);
+}
+
+static void
+foo(int * interp, Pcc_cell *c)
+{
+ mark_cell(interp, c, g_pvc);
+}
+
+static struct Pcc_cell *
+__attribute__((noinline,noclone))
+getnull(void)
+{
+ return (struct Pcc_cell *) 0;
+}
+
+
+int main()
+{
+ int i;
+
+ cond = 1;
+ for (i = 0; i < 100; i++)
+ foo (&gi, getnull ());
+ return 0;
+}
+
+
+void
+bar_1 (int * interp, Pcc_cell *c)
+{
+ c->bla += 1;
+ mark_cell(interp, c, g_pvc);
+}
+
+void
+bar_2 (int * interp, Pcc_cell *c, struct PVC pvc)
+{
+ c->bla += 2;
+ mark_cell(interp, c, pvc);
+}
+
diff --git a/gcc/testsuite/gcc.dg/torture/pr50396.c b/gcc/testsuite/gcc.dg/torture/pr50396.c
new file mode 100644
index 000000000..aa17ebdaa
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr50396.c
@@ -0,0 +1,22 @@
+/* { dg-do run } */
+/* { dg-add-options ieee } */
+
+extern void abort (void);
+typedef float vf128 __attribute__((vector_size(16)));
+typedef float vf64 __attribute__((vector_size(8)));
+int main()
+{
+#if !__FINITE_MATH_ONLY__
+#if __FLT_HAS_QUIET_NAN__
+ vf128 v = (vf128){ 0.f, 0.f, 0.f, 0.f };
+ vf64 u = (vf64){ 0.f, 0.f };
+ v = v / (vf128){ 0.f, 0.f, 0.f, 0.f };
+ if (v[0] == v[0])
+ abort ();
+ u = u / (vf64){ 0.f, 0.f };
+ if (u[0] == u[0])
+ abort ();
+#endif
+#endif
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr50472.c b/gcc/testsuite/gcc.dg/torture/pr50472.c
new file mode 100644
index 000000000..280f2c4ea
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr50472.c
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-options "-fdump-tree-optimized" } */
+
+static const unsigned int foo = 1;
+unsigned int test( void )
+{
+ const volatile unsigned int *bar = &foo;
+ return ( *bar );
+}
+
+/* { dg-final { scan-tree-dump-not "return 1" "optimized" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
diff --git a/gcc/testsuite/gcc.dg/torture/pr50723.c b/gcc/testsuite/gcc.dg/torture/pr50723.c
new file mode 100644
index 000000000..24e490fc6
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr50723.c
@@ -0,0 +1,26 @@
+/* { dg-do compile } */
+
+typedef short unsigned int wchar_t;
+typedef unsigned int size_t;
+int* _errno(void);
+int WideCharToMultiByte (wchar_t *);
+int __attribute__ ((__nonnull__ (1)))
+__wcrtomb_cp (char *dst, wchar_t wc, const unsigned int cp,
+ const unsigned int mb_max)
+{
+ if (cp == 0) {
+ if (wc > 255)
+ (*_errno()) = 42;
+ return 1;
+ }
+ else
+ return WideCharToMultiByte (&wc);
+}
+void wcsrtombs (char *dst, const wchar_t *pwc, unsigned int cp,
+ unsigned int mb_max)
+{
+ if ((__wcrtomb_cp (dst, *pwc, cp, mb_max)) <= 0)
+ return;
+ if ((__wcrtomb_cp (dst, *pwc, cp, mb_max)) <= 0)
+ return;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr51042.c b/gcc/testsuite/gcc.dg/torture/pr51042.c
new file mode 100644
index 000000000..05961c4ac
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr51042.c
@@ -0,0 +1,22 @@
+/* { dg-do compile } */
+
+int a, b;
+
+void
+foo (int x)
+{
+ int e[2];
+ int d;
+ while (x)
+ {
+ for (d = 0; d <= 1; d = 1)
+ if (e[a])
+ break;
+ for (b = 0; b <= 0; b = 1)
+ {
+ e[a] = a;
+ if (a)
+ break;
+ }
+ }
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr51070-2.c b/gcc/testsuite/gcc.dg/torture/pr51070-2.c
new file mode 100644
index 000000000..f21eb3acb
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr51070-2.c
@@ -0,0 +1,35 @@
+/* { dg-do compile } */
+/* { dg-options "-fno-inline" } */
+
+int
+func_4 (int si1, int si2)
+{
+ return si1;
+}
+
+int
+func_14 (int left, int right)
+{
+ return 1;
+}
+
+int
+func_37 (int left, int right)
+{
+ return left;
+}
+
+int g_92[1024];
+int g_95[1024];
+int g_224;
+int g_352[1024];
+int
+func_9 ()
+{
+ for (; g_224; g_224 += 1)
+ {
+ g_95[0] = func_4 (func_37 (g_92[g_224], 0), 0);
+ g_92[g_224] = 0, g_352[g_224] = func_14 (0, 0);
+ }
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr51070.c b/gcc/testsuite/gcc.dg/torture/pr51070.c
new file mode 100644
index 000000000..cc06a90c8
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr51070.c
@@ -0,0 +1,34 @@
+/* { dg-do compile } */
+
+int
+func_4 (int si1, int si2)
+{
+ return si1;
+}
+
+int
+func_14 (int left, int right)
+{
+ return 1;
+}
+
+int
+func_37 (int left, int right)
+{
+ return left;
+}
+
+int g_92[1024];
+int g_95[1024];
+int g_224;
+int g_352[1024];
+int
+func_9 ()
+{
+ for (; g_224; g_224 += 1)
+ {
+ g_95[0] = func_4 (func_37 (g_92[g_224], 0), 0);
+ g_92[g_224] = 0, g_352[g_224] = func_14 (0, 0);
+ }
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr51071-2.c b/gcc/testsuite/gcc.dg/torture/pr51071-2.c
new file mode 100644
index 000000000..f66a89f39
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr51071-2.c
@@ -0,0 +1,38 @@
+/* { dg-do compile } */
+/* { dg-options "-fno-delete-null-pointer-checks" } */
+
+extern struct module __this_module;
+static inline void
+trace_module_get (struct module *mod, unsigned long ip) { }
+struct module;
+static inline __attribute__((no_instrument_function))
+int try_module_get(struct module *module)
+{
+ int ret = 1;
+ if (module)
+ {
+ if (module_is_live(module))
+ {
+ __label__ __here;
+ asm("");
+ __here:
+ trace_module_get(module, (unsigned long)&&__here);
+ }
+ else
+ ret = 0;
+ }
+ return ret;
+}
+struct net_device;
+struct net_device_ops {
+ int (*ndo_open)(struct net_device *dev);
+};
+int t3e3_open(struct net_device *dev)
+{
+ int ret = hdlc_open(dev);
+ if (ret)
+ return ret;
+ try_module_get((&__this_module));
+ return 0;
+}
+const struct net_device_ops t3e3_ops = { .ndo_open = t3e3_open };
diff --git a/gcc/testsuite/gcc.dg/torture/pr51071.c b/gcc/testsuite/gcc.dg/torture/pr51071.c
new file mode 100644
index 000000000..99af9587d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr51071.c
@@ -0,0 +1,33 @@
+/* { dg-do compile } */
+
+void foo (void);
+void bar (void *);
+extern int t;
+
+static void kmalloc_large (int size, int flags)
+{
+ (void) size;
+ (void) flags;
+ foo ();
+ bar (({__here:&&__here;}));
+}
+
+static void kmalloc (int size, int flags)
+{
+ if (size)
+ {
+ if ((unsigned long) size > 0x1000)
+ kmalloc_large (size, flags);
+
+ if (flags)
+ bar (({__here:&&__here;}));
+ }
+}
+
+void compress_file_range (int i, int j, int k)
+{
+ int nr_pages = ({j < k;});
+
+ if (i || t)
+ kmalloc (0x1000UL * nr_pages, 0x40UL);
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr51106-1.c b/gcc/testsuite/gcc.dg/torture/pr51106-1.c
new file mode 100644
index 000000000..10b3b682b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr51106-1.c
@@ -0,0 +1,14 @@
+/* PR target/51106 */
+/* { dg-do "compile" } */
+/* { dg-skip-if "RTL error" { "*-*-*" } { "-fno-fat-lto-objects" } { "" } } */
+
+int
+foo (int x)
+{
+ asm goto ("" : : "i" (x) : : lab); /* { dg-error "impossible constraint" } */
+ return 1;
+lab:
+ return 0;
+}
+
+/* { dg-warning "probably doesn.t match constraints" "" { target *-*-* } 8 } */
diff --git a/gcc/testsuite/gcc.dg/torture/pr51106-2.c b/gcc/testsuite/gcc.dg/torture/pr51106-2.c
new file mode 100644
index 000000000..e69bf1b01
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr51106-2.c
@@ -0,0 +1,14 @@
+/* PR target/51106 */
+/* { dg-do "compile" } */
+/* { dg-skip-if "RTL error" { "*-*-*" } { "-fno-fat-lto-objects" } { "" } } */
+
+int
+bar (int x)
+{
+ asm goto ("" : : "i" (x) : : lab); /* { dg-error "impossible constraint" } */
+ __builtin_unreachable ();
+lab:
+ return 0;
+}
+
+/* { dg-warning "probably doesn.t match constraints" "" { target *-*-* } 8 } */
diff --git a/gcc/testsuite/gcc.dg/torture/pr52060.c b/gcc/testsuite/gcc.dg/torture/pr52060.c
new file mode 100644
index 000000000..44207a503
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr52060.c
@@ -0,0 +1,57 @@
+/* PR rtl-optimization/52060 */
+/* { dg-do run { target int32plus } } */
+
+extern void abort (void);
+union U { float f; unsigned int i; };
+
+static inline __attribute__((always_inline)) unsigned int
+foo (float x)
+{
+ union U u;
+ unsigned int a, b, c;
+ int d;
+ int e;
+ u.f = x;
+ d = ((unsigned) u.i >> 23) & 0xFF;
+ c = d < 126 ? 0 : ~0;
+ e = 127 + 30 - d;
+ a = (u.i << 8) | 0x80000000U;
+ b = a & ((1 << e) - 1);
+ a = a >> e;
+ c &= (b | (a & 2)) ? ~0 : ~1;
+ a = ((a + 1U) >> 1) & c;
+ return a;
+}
+
+__attribute__((noinline)) unsigned int
+bar (float x)
+{
+ unsigned int a, b, c;
+ static const unsigned int d[128] =
+ {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 6, 7
+ };
+ a = foo (1048575.0f * x);
+ c = d[a >> 13];
+ b = (c << 13) | ((a >> (7 - c)) & 0x1fff);
+ return b;
+}
+
+int
+main ()
+{
+ union U u;
+ u.f = 1048575.0f;
+ if (sizeof (u.i) == sizeof (u.f)
+ && u.i == 0x497ffff0U
+ && bar (1.0f) != 65535)
+ abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr52407.c b/gcc/testsuite/gcc.dg/torture/pr52407.c
new file mode 100644
index 000000000..917e9db3f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr52407.c
@@ -0,0 +1,34 @@
+/* { dg-do run } */
+/* { dg-options "-fno-common" { target hppa*-*-hpux* } } */
+
+extern void abort (void);
+
+typedef long long T;
+typedef T vl_t __attribute__((vector_size(2 * sizeof (T))));
+
+vl_t ul[4], vl[4] = { { 1, 2 }, { 3, 4 }, { 5, 6 }, { 7, 8 } };
+
+static void
+mul_vl_l(vl_t *u, vl_t *v, T x, int m)
+{
+ vl_t w;
+ T *p = (T *)&w;
+ p[0] = p[1] = x;
+ while (m--)
+ *u++ = *v++ * w;
+}
+
+int
+main(int argc, char *argv[])
+{
+ int i;
+ T *pl;
+
+ pl = (T *) &ul;
+ mul_vl_l(ul, vl, 2, 4);
+ for (i = 0; i < 8; i++)
+ if (pl[i] != 2 * (i + 1))
+ abort ();
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr52693.c b/gcc/testsuite/gcc.dg/torture/pr52693.c
new file mode 100644
index 000000000..93e0680ac
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr52693.c
@@ -0,0 +1,33 @@
+/* { dg-do run } */
+
+struct pair
+{
+ int x;
+ int y;
+};
+
+struct array
+{
+ struct pair elems[ 2 ];
+ unsigned index;
+};
+
+extern void abort ();
+
+void __attribute__ ((noinline,noclone))
+test_results (int x1, int y1, int x2, int y2)
+{
+ if (x1 != x2 || y1 != y2)
+ abort ();
+}
+
+int
+main (void)
+{
+ struct array arr = {{{1,2}, {3,4}}, 1};
+ struct pair last = arr.elems[arr.index];
+
+ test_results ( last.x, last.y, arr.elems[1].x, arr.elems[1].y);
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr53790.c b/gcc/testsuite/gcc.dg/torture/pr53790.c
new file mode 100644
index 000000000..0abd3dd83
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr53790.c
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+
+typedef struct s {
+ int value;
+} s_t;
+
+static inline int
+read(s_t const *var)
+{
+ return var->value;
+}
+
+int main()
+{
+ extern union u extern_var;
+ return read((s_t *)&extern_var);
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr53908.c b/gcc/testsuite/gcc.dg/torture/pr53908.c
new file mode 100644
index 000000000..e96b63522
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr53908.c
@@ -0,0 +1,288 @@
+/* { dg-do run } */
+/* SEGV at comment below. */
+typedef unsigned int size_t;
+typedef enum har {
+ he_fatal = (-199),
+ he_not_initialized,
+ he_bad_input,
+ he_memory_too_small,
+ he_bad_action,
+ he_duplicate,
+ he_bad_nonce,
+ he_stale_nonce,
+ he_bad_credentials,
+ he_bad_user,
+ he_no_such_user,
+ he_bad_passwd,
+ he_unknown_auth_scheme,
+ he_not_found,
+ he_failed_digest_file_check,
+ he_failed_digest_file_save,
+ he_process_not_privileged,
+ he_other,
+ he_end_of_range,
+ ha_no_error = 0,
+ ha_no_value = 1
+} har;
+typedef enum realm_type
+{
+ axis_realm = 0,
+ ws_realm
+} realm_type;
+
+__attribute__((__noclone__, __noinline__))
+har has_www_auth(char *, size_t, realm_type, har);
+
+__attribute__((__noclone__, __noinline__))
+har has_auth_user(const char *, const char *, realm_type, char *, size_t);
+
+__attribute__((__noclone__, __noinline__))
+char *ha_get_string_value(void);
+
+typedef struct
+{
+ unsigned int track_id;
+ char* user;
+ char* realm;
+ char* authent;
+ int internal_realm;
+} request;
+enum user_response {
+ file_not_found_user_response = -3,
+ access_denied_user_response = -2,
+ no_user_response = -1,
+ ok_user_response = 0
+};
+struct realm_group {
+ char *name;
+ int id;
+ struct realm_group *next;
+};
+struct realm {
+ char *name;
+ char *space;
+ struct realm_group *groups;
+ struct realm *next;
+};
+struct user_info {
+ char *name;
+ int no_groups;
+ int groups[128];
+ struct user_info *next;
+};
+static struct user_info *find_user(const char *user_name);
+static int is_member_of_groups(const struct user_info *user_item,
+ const struct realm_group *groups);
+int authent_author(request *req);
+struct realm *realms = ((void *)0);
+struct user_info *users = ((void *)0);
+static struct user_info*
+find_user(const char *user_name)
+{
+ struct user_info *user_item;
+ user_item = users;
+ while (user_item != ((void *)0)) {
+ /* SEGV due to NULL access here on user_name. See also comment below. */
+ if ((__builtin_strcmp(user_item->name, user_name) == 0))
+ break;
+ user_item = user_item->next;
+ }
+ return user_item;
+}
+static int
+is_member_of_groups(const struct user_info *user_item,
+ const struct realm_group *groups)
+{
+ const struct realm_group *group_item;
+ int i;
+ group_item = groups;
+ while (group_item != ((void *)0)) {
+ for (i = 0; i < user_item->no_groups; i++)
+ if (user_item->groups[i] == group_item->id)
+ return 0;
+ group_item = group_item->next;
+ }
+ return -1;
+}
+char *foo (void) __attribute__((__noclone__, __noinline__));
+char* g_strdup (const char *str) __attribute__((__malloc__, __noclone__, __noinline__));
+int g_strcmp0 (const char *str1, const char *str2);
+static int
+is_basic(char **user)
+{
+ char *passwd_ptr;
+ char *authent = foo();
+ passwd_ptr = __builtin_strchr(authent, ':');
+ if (passwd_ptr != ((void *)0)) {
+ *user = g_strdup(authent);
+ return 0;
+ }
+ return -1;
+}
+static int
+is_digest(char **user)
+{
+ int ret_val = -1;
+ char *authent;
+ authent = ha_get_string_value();
+ if (authent) {
+ *user = g_strdup(authent);
+ ret_val = 0;
+ }
+ return ret_val;
+}
+__attribute__((__noclone__, __noinline__))
+void g_free (void * mem);
+static enum user_response
+get_user_info_from_header(const realm_type type,
+ char **user_name,
+ struct user_info **user_item)
+{
+ int ret_val = no_user_response;
+ if ((type == ws_realm)) {
+ if (is_basic(user_name) == 0)
+ ret_val = access_denied_user_response;
+ if (is_digest(user_name) == 0)
+ ret_val = ok_user_response;
+ } else {
+ if (is_basic(user_name) < 0 &&
+ /* Load of *user_name here, but not after the is_digest call. */
+ is_digest(user_name) < 0)
+ ;
+ else if ((*user_item = find_user(*user_name)) != ((void *)0))
+ ret_val = ok_user_response;
+ else
+ ret_val = access_denied_user_response;
+ if (ret_val != ok_user_response)
+ g_free(*user_name);
+ }
+ return ret_val;
+}
+static enum user_response
+authenticate_user(request *req,
+ char **user_name,
+ struct user_info **user_item)
+{
+ char *authent = ((void *)0);
+ har resp = ha_no_value;
+ enum user_response user_resp;
+ int ret_val = no_user_response;
+ if (req->authent && __builtin_strlen(req->authent)) {
+ authent = req->authent;
+ user_resp = get_user_info_from_header(req->internal_realm,
+ user_name,
+ user_item);
+ if (user_resp == ok_user_response) {
+ resp = has_auth_user(authent, 0, req->internal_realm, "", 1);
+ if (resp == ha_no_error)
+ ret_val = ok_user_response;
+ else if (resp != he_stale_nonce)
+ ret_val = access_denied_user_response;
+ } else if (user_resp == access_denied_user_response)
+ ret_val = access_denied_user_response;
+ }
+ if (resp != he_memory_too_small && resp != ha_no_error)
+ resp = has_www_auth("", 1, req->internal_realm, resp);
+ return ret_val;
+}
+
+int __attribute__ ((__noinline__, __noclone__))
+authent_author(request *req)
+{
+ struct realm *realm;
+ char *user_name = ((void *)0);
+ struct user_info *user_item = ((void *)0);
+ int res = 0;
+ asm ("");
+ realm = realms;
+ if (__builtin_strcmp("Wsd", realm->name) == 0) {
+ req->internal_realm = ws_realm;
+ is_digest(&user_name);
+ }
+ if (authenticate_user(req, &user_name, &user_item) < 0) {
+ if (user_name != ((void *)0))
+ req->user = user_name;
+ res = -2;
+ goto authent_author_return;
+ }
+ if (is_member_of_groups(user_item, realm->groups) < 0)
+ res = -1;
+authent_author_return:
+ return res;
+}
+
+int good0, good1, good2;
+
+__attribute__ ((__noinline__, __noclone__))
+char *foo(void)
+{
+ asm ("");
+ good0++;
+ return "";
+}
+
+__attribute__ ((__noinline__, __noclone__))
+char *ha_get_string_value(void)
+{
+ asm ("");
+ good1++;
+ return "f";
+}
+
+__attribute__ ((__noinline__, __noclone__))
+har has_auth_user(const char *a, const char *b, realm_type c, char *d, size_t e)
+{
+ asm ("");
+ if (*a != 'z' || a[1] != 0 || b != 0 || c != axis_realm || *d != 0
+ || e != 1)
+ __builtin_abort ();
+ return ha_no_error;
+}
+
+__attribute__ ((__noinline__, __noclone__))
+har has_www_auth(char *a, size_t b, realm_type c, har d)
+{
+ (void)(*a+b+c+d);
+ asm ("");
+ __builtin_abort ();
+}
+
+
+char *strdupped_user = "me";
+__attribute__((__malloc__, __noclone__, __noinline__))
+char* g_strdup (const char *str)
+{
+ asm ("");
+ if (*str != 'f')
+ __builtin_abort ();
+ good2++;
+ return strdupped_user;
+}
+
+__attribute__((__noclone__, __noinline__))
+void g_free (void * mem)
+{
+ (void)mem;
+ asm ("");
+ __builtin_abort ();
+}
+
+struct user_info me = { .name = "me", .no_groups = 1, .groups = {42}, .next = 0};
+struct user_info you = { .name = "you", .next = &me};
+struct realm_group xgroups = { .name = "*", .id = 42, .next = 0};
+
+int main(void)
+{
+ char *orig_user = "?";
+ struct realm r = { .name = "x", .space = "space?", .groups = &xgroups, .next = 0};
+ request req = { .user = orig_user, .realm = "!", .authent = "z",
+ .internal_realm = axis_realm};
+ realms = &r;
+ users = &you;
+ if (authent_author (&req) != 0 || good0 != 1 || good1 != 1 || good2 != 1
+ || req.user != orig_user
+ || req.internal_realm != axis_realm)
+ __builtin_abort ();
+ __builtin_exit (0);
+}
+
diff --git a/gcc/testsuite/gcc.dg/torture/pr55755.c b/gcc/testsuite/gcc.dg/torture/pr55755.c
new file mode 100644
index 000000000..3c8bb6ba4
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr55755.c
@@ -0,0 +1,43 @@
+/* { dg-do run } */
+/* { dg-require-effective-target int32plus } */
+
+struct S4
+{
+ unsigned f0:24;
+} __attribute__((__packed__));
+
+struct S4 g_10 = {
+ 6210831
+};
+
+struct S5
+{
+ int i;
+ struct S4 l_8[2];
+} __attribute__((__packed__));
+
+int a, b;
+
+struct S4 func_2 (int x)
+{
+ struct S5 l = {
+ 0,
+ {{0}, {0}}
+ };
+ l.i = a;
+ g_10 = l.l_8[1];
+ for (; x<2; x++) {
+ struct S4 tmp = {
+ 11936567
+ };
+ l.l_8[x] = tmp;
+ }
+ b = l.i;
+ return g_10;
+}
+
+int main (void)
+{
+ func_2 (0);
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pta-callused-1.c b/gcc/testsuite/gcc.dg/torture/pta-callused-1.c
new file mode 100644
index 000000000..dfbde86c6
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pta-callused-1.c
@@ -0,0 +1,25 @@
+/* { dg-do run } */
+/* { dg-options "-fdump-tree-alias" } */
+/* { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */
+
+volatile int i;
+int ** __attribute__((noinline,pure)) foo(int **p) { i; return p; }
+int bar(void)
+{
+ int i = 0, j = 1;
+ int *p, **q;
+ p = &i;
+ q = foo(&p);
+ *q = &j;
+ return *p;
+}
+extern void abort (void);
+int main()
+{
+ if (bar() != 1)
+ abort ();
+ return 0;
+}
+
+/* { dg-final { scan-tree-dump "p.._., points-to vars: { i j }" "alias" } } */
+/* { dg-final { cleanup-tree-dump "alias" } } */
diff --git a/gcc/testsuite/gcc.dg/torture/pta-escape-1.c b/gcc/testsuite/gcc.dg/torture/pta-escape-1.c
new file mode 100644
index 000000000..2aafe80b3
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pta-escape-1.c
@@ -0,0 +1,34 @@
+/* { dg-do run } */
+/* { dg-options "-fdump-tree-alias" } */
+/* { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */
+
+int *p;
+void __attribute__((noinline,noclone))
+bar (void)
+{
+ *p = 1;
+}
+int __attribute__((noinline,noclone))
+foo (__SIZE_TYPE__ addr)
+{
+ int i;
+ /* q points to ANYTHING */
+ int **q = (int **)addr;
+ /* this store needs to cause i to escape */
+ *q = &i;
+ i = 0;
+ /* and thus be clobbered by this function call */
+ bar ();
+ return i;
+}
+extern void abort (void);
+int
+main()
+{
+ if (foo ((__SIZE_TYPE__)&p) != 1)
+ abort ();
+ return 0;
+}
+
+/* { dg-final { scan-tree-dump "ESCAPED = {\[^\n\}\]* i \[^\n\}\]*}" "alias" } } */
+/* { dg-final { cleanup-tree-dump "alias" } } */
diff --git a/gcc/testsuite/gcc.dg/torture/pta-ptrarith-1.c b/gcc/testsuite/gcc.dg/torture/pta-ptrarith-1.c
new file mode 100644
index 000000000..d41868eb4
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pta-ptrarith-1.c
@@ -0,0 +1,33 @@
+/* { dg-do run } */
+/* { dg-options "-fdump-tree-alias" } */
+/* { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */
+
+struct Foo {
+ int *p;
+};
+
+void __attribute__((noinline))
+foo (void *p)
+{
+ struct Foo *f = (struct Foo *)p - 1;
+ *f->p = 0;
+}
+
+int bar (void)
+{
+ struct Foo f;
+ int i = 1;
+ f.p = &i;
+ foo (&f + 1);
+ return i;
+}
+extern void abort (void);
+int main()
+{
+ if (bar () != 0)
+ abort ();
+ return 0;
+}
+
+/* { dg-final { scan-tree-dump "ESCAPED = {\[^\n\}\]* i f \[^\n\}\]*}" "alias" } } */
+/* { dg-final { cleanup-tree-dump "alias" } } */
diff --git a/gcc/testsuite/gcc.dg/torture/pta-ptrarith-2.c b/gcc/testsuite/gcc.dg/torture/pta-ptrarith-2.c
new file mode 100644
index 000000000..fb5b2e15e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pta-ptrarith-2.c
@@ -0,0 +1,36 @@
+/* { dg-do run } */
+/* { dg-options "-fdump-tree-alias" } */
+/* { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */
+
+struct Foo {
+ int **p;
+ int **q;
+};
+
+int __attribute__((noinline))
+bar (void)
+{
+ struct Foo f;
+ int j, i = 1;
+ char *p;
+ int *x = &i;
+ int *y = &j;
+ f.p = &y;
+ f.q = &x;
+ p = (char *)&f;
+ for (j = 0; j < sizeof (int *); ++j)
+ p++;
+ return ***(int ***)p;
+}
+extern void abort (void);
+int main()
+{
+ if (bar () != 1)
+ abort ();
+ return 0;
+}
+
+/* In theory = { i } is the correct solution. But it's not easy to scan
+ for that reliably, so just use what we create now. */
+/* { dg-final { scan-tree-dump "= { i j }" "alias" } } */
+/* { dg-final { cleanup-tree-dump "alias" } } */
diff --git a/gcc/testsuite/gcc.dg/torture/pta-ptrarith-3.c b/gcc/testsuite/gcc.dg/torture/pta-ptrarith-3.c
new file mode 100644
index 000000000..6c08319d8
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pta-ptrarith-3.c
@@ -0,0 +1,37 @@
+/* { dg-do run } */
+/* { dg-options "-fdump-tree-alias" } */
+/* { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */
+
+extern void abort (void);
+struct X {
+ int *p;
+ int *q;
+ int *r;
+};
+int __attribute__((noinline))
+foo(int i, int j, int k, int off)
+{
+ struct X x;
+ int **p, *q;
+ x.p = &i;
+ x.q = &j;
+ x.r = &k;
+ p = &x.q;
+ p += off;
+ /* *p points to { i, j, k } */
+ q = *p;
+ return *q;
+}
+int main()
+{
+ if (foo(1, 2, 3, -1) != 1)
+ abort ();
+ if (foo(1, 2, 3, 0) != 2)
+ abort ();
+ if (foo(1, 2, 3, 1) != 3)
+ abort ();
+ return 0;
+}
+
+/* { dg-final { scan-tree-dump "q_., points-to vars: { i j k }" "alias" } } */
+/* { dg-final { cleanup-tree-dump "alias" } } */
diff --git a/gcc/testsuite/gcc.dg/torture/pta-structcopy-1.c b/gcc/testsuite/gcc.dg/torture/pta-structcopy-1.c
new file mode 100644
index 000000000..bdb2acb04
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pta-structcopy-1.c
@@ -0,0 +1,34 @@
+/* { dg-do run } */
+/* { dg-options "-fno-tree-sra -fdump-tree-alias" } */
+/* { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */
+
+struct X
+{
+ long l1;
+ struct Y
+ {
+ long l2;
+ int *p;
+ } y;
+};
+int i;
+static int
+foo (struct X *x)
+{
+ struct Y y = x->y;
+ *y.p = 0;
+ i = 1;
+ return *y.p;
+}
+extern void abort (void);
+int main()
+{
+ struct X x;
+ x.y.p = &i;
+ if (foo(&x) != 1)
+ abort ();
+ return 0;
+}
+
+/* { dg-final { scan-tree-dump "points-to vars: { i }" "alias" } } */
+/* { dg-final { cleanup-tree-dump "alias" } } */
diff --git a/gcc/testsuite/gcc.dg/torture/reassoc-1.c b/gcc/testsuite/gcc.dg/torture/reassoc-1.c
new file mode 100644
index 000000000..f0c9014cc
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/reassoc-1.c
@@ -0,0 +1,24 @@
+/* { dg-do run } */
+
+int x;
+
+int __attribute__((noinline))
+foo(int a, int b, int w)
+{
+ int tmp1 = a * w;
+ int tmp2 = b * w;
+ x = tmp1;
+ return tmp1 + tmp2;
+}
+
+extern void abort (void);
+
+int main()
+{
+ if (foo(1, 2, 3) != 9)
+ abort ();
+ if (x != 3)
+ abort ();
+ return 0;
+}
+
diff --git a/gcc/testsuite/gcc.dg/torture/ssa-pta-fn-1.c b/gcc/testsuite/gcc.dg/torture/ssa-pta-fn-1.c
new file mode 100644
index 000000000..80785f01f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/ssa-pta-fn-1.c
@@ -0,0 +1,62 @@
+/* { dg-do run } */
+/* { dg-options "-fdump-tree-alias" } */
+/* { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */
+
+extern void abort (void);
+int *glob;
+int dummy;
+
+int * __attribute__((noinline,const))
+foo_const(int *p) { return p; }
+
+int * __attribute__((noinline,pure))
+foo_pure(int *p) { return p + dummy; }
+
+int * __attribute__((noinline))
+foo_normal(int *p) { glob = p; return p; }
+
+void test_const(void)
+{
+ int i;
+ int *p = &i;
+ int *q_const = foo_const(p);
+ *p = 1;
+ *q_const = 2;
+ if (*p != 2)
+ abort ();
+}
+
+void test(void)
+{
+ int i;
+ int *p = &i;
+ int *q_normal = foo_normal(p);
+ *p = 1;
+ *q_normal = 2;
+ if (*p != 2)
+ abort ();
+}
+
+void test_pure(void)
+{
+ int i;
+ int *p = &i;
+ int *q_pure = foo_pure(p);
+ *p = 1;
+ *q_pure = 2;
+ if (*p != 2)
+ abort ();
+}
+
+int main()
+{
+ test_const();
+ test();
+ test_pure();
+ return 0;
+}
+
+/* { dg-final { scan-tree-dump "q_const_., points-to non-local, points-to vars: { i }" "alias" } } */
+/* { dg-final { scan-tree-dump "q_pure_., points-to non-local, points-to escaped, points-to vars: { i }" "alias" } } */
+/* { dg-final { scan-tree-dump "q_normal_., points-to non-local, points-to escaped, points-to vars: { }" "alias" } } */
+/* { dg-final { cleanup-tree-dump "alias" } } */
diff --git a/gcc/testsuite/gcc.dg/torture/stackalign/alloca-1.c b/gcc/testsuite/gcc.dg/torture/stackalign/alloca-1.c
new file mode 100644
index 000000000..e226e7f03
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/stackalign/alloca-1.c
@@ -0,0 +1,45 @@
+/* { dg-do run } */
+/* { dg-skip-if "Stack alignment is too small" { hppa*-*-hpux* } "*" "" } */
+
+#include "check.h"
+
+#ifndef ALIGNMENT
+#define ALIGNMENT 64
+#endif
+
+typedef int aligned __attribute__((aligned(ALIGNMENT)));
+
+int global;
+
+void
+bar (char *p, int size)
+{
+ __builtin_strncpy (p, "good", size);
+}
+
+void
+foo (int size)
+{
+ char *p = __builtin_alloca (size + 1);
+ aligned i;
+
+ bar (p, size);
+ if (__builtin_strncmp (p, "good", size) != 0)
+ {
+#ifdef DEBUG
+ p[size] = '\0';
+ printf ("Failed: %s != good\n", p);
+#endif
+ abort ();
+ }
+
+ if (check_int (&i, __alignof__(i)) != i)
+ abort ();
+}
+
+int
+main()
+{
+ foo (5);
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/stackalign/alloca-2.c b/gcc/testsuite/gcc.dg/torture/stackalign/alloca-2.c
new file mode 100644
index 000000000..139b74ed9
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/stackalign/alloca-2.c
@@ -0,0 +1,49 @@
+/* PR middle-end/37009 */
+/* { dg-do run { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */
+/* { dg-options "-msse2" } */
+/* { dg-require-effective-target sse2_runtime } */
+
+#include <emmintrin.h>
+#include "check.h"
+
+#ifndef ALIGNMENT
+#define ALIGNMENT 16
+#endif
+
+typedef int aligned __attribute__((aligned(ALIGNMENT)));
+
+void
+bar (char *p, int size)
+{
+ __builtin_strncpy (p, "good", size);
+}
+
+void
+__attribute__ ((noinline))
+foo (__m128 x, __m128 y ,__m128 z , int size)
+{
+ char *p = __builtin_alloca (size + 1);
+ aligned i;
+
+ bar (p, size);
+ if (__builtin_strncmp (p, "good", size) != 0)
+ {
+#ifdef DEBUG
+ p[size] = '\0';
+ printf ("Failed: %s != good\n", p);
+#endif
+ abort ();
+ }
+
+ if (check_int (&i, __alignof__(i)) != i)
+ abort ();
+}
+
+int
+main (void)
+{
+ __m128 x = { 1.0 };
+ foo (x, x, x, 5);
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/stackalign/alloca-3.c b/gcc/testsuite/gcc.dg/torture/stackalign/alloca-3.c
new file mode 100644
index 000000000..31cb0c472
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/stackalign/alloca-3.c
@@ -0,0 +1,49 @@
+/* PR middle-end/37009 */
+/* { dg-do run { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */
+/* { dg-options "-msse2" } */
+/* { dg-require-effective-target sse2_runtime } */
+
+#include <emmintrin.h>
+#include "check.h"
+
+#ifndef ALIGNMENT
+#define ALIGNMENT 16
+#endif
+
+typedef int aligned __attribute__((aligned(ALIGNMENT)));
+
+void
+bar (char *p, int size)
+{
+ __builtin_strncpy (p, "good", size);
+}
+
+void
+__attribute__ ((noinline))
+foo (__m128 x, __m128 y ,__m128 z ,__m128 a, int size)
+{
+ char *p = __builtin_alloca (size + 1);
+ aligned i;
+
+ bar (p, size);
+ if (__builtin_strncmp (p, "good", size) != 0)
+ {
+#ifdef DEBUG
+ p[size] = '\0';
+ printf ("Failed: %s != good\n", p);
+#endif
+ abort ();
+ }
+
+ if (check_int (&i, __alignof__(i)) != i)
+ abort ();
+}
+
+int
+main (void)
+{
+ __m128 x = { 1.0 };
+ foo (x, x, x, x, 5);
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/stackalign/alloca-4.c b/gcc/testsuite/gcc.dg/torture/stackalign/alloca-4.c
new file mode 100644
index 000000000..c3e554acf
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/stackalign/alloca-4.c
@@ -0,0 +1,41 @@
+/* PR middle-end/37009 */
+/* { dg-do run { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */
+/* { dg-options "-mincoming-stack-boundary=2 -mpreferred-stack-boundary=2" } */
+
+#include "check.h"
+
+void
+bar (char *p, int size)
+{
+ __builtin_strncpy (p, "good", size);
+}
+
+void
+__attribute__ ((noinline))
+foo (double x, double y ,double z ,double a, int size)
+{
+ char *p = __builtin_alloca (size + 1);
+ double i;
+
+ bar (p, size);
+ if (__builtin_strncmp (p, "good", size) != 0)
+ {
+#ifdef DEBUG
+ p[size] = '\0';
+ printf ("Failed: %s != good\n", p);
+#endif
+ abort ();
+ }
+
+ check (&i, __alignof__(i));
+}
+
+int
+main (void)
+{
+ double x = 1.0 ;
+
+ foo (x, x, x, x, 5);
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/stackalign/alloca-5.c b/gcc/testsuite/gcc.dg/torture/stackalign/alloca-5.c
new file mode 100644
index 000000000..2ef4443f2
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/stackalign/alloca-5.c
@@ -0,0 +1,32 @@
+/* PR middle-end/45234 */
+/* { dg-do run { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */
+/* { dg-options "-mincoming-stack-boundary=2 -mpreferred-stack-boundary=2" } */
+
+#include "check.h"
+
+void
+__attribute__ ((noinline))
+bar (__float128 f)
+{
+ check (&f, __alignof__(f));
+}
+
+int
+main (void)
+{
+ char *p = __builtin_alloca (6);
+
+ bar (0);
+
+ __builtin_strncpy (p, "good", 5);
+ if (__builtin_strncmp (p, "good", 5) != 0)
+ {
+#ifdef DEBUG
+ p[5] = '\0';
+ printf ("Failed: %s != good\n", p);
+#endif
+ abort ();
+ }
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/stackalign/alloca-6.c b/gcc/testsuite/gcc.dg/torture/stackalign/alloca-6.c
new file mode 100644
index 000000000..f0e4513de
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/stackalign/alloca-6.c
@@ -0,0 +1,34 @@
+/* PR middle-end/45234 */
+/* { dg-do run { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */
+/* { dg-options "-mincoming-stack-boundary=2 -mpreferred-stack-boundary=2" } */
+
+#include "check.h"
+
+void
+__attribute__ ((noinline))
+bar (__float128 f)
+{
+ check (&f, __alignof__(f));
+}
+
+volatile int z = 6;
+
+int
+main (void)
+{
+ char *p = __builtin_alloca (z);
+
+ bar (0);
+
+ __builtin_strncpy (p, "good", 5);
+ if (__builtin_strncmp (p, "good", 5) != 0)
+ {
+#ifdef DEBUG
+ p[z - 1] = '\0';
+ printf ("Failed: %s != good\n", p);
+#endif
+ abort ();
+ }
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/stackalign/builtin-apply-1.c b/gcc/testsuite/gcc.dg/torture/stackalign/builtin-apply-1.c
new file mode 100644
index 000000000..38b384e7c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/stackalign/builtin-apply-1.c
@@ -0,0 +1,9 @@
+/* PR 11184 */
+/* Origin: Dara Hazeghi <dhazeghi@yahoo.com> */
+
+void *
+objc_msg_sendv (char * arg_frame, void (*foo)())
+{
+ return __builtin_apply ( foo, arg_frame, 4);
+}
+
diff --git a/gcc/testsuite/gcc.dg/torture/stackalign/builtin-apply-2.c b/gcc/testsuite/gcc.dg/torture/stackalign/builtin-apply-2.c
new file mode 100644
index 000000000..a1ba20fce
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/stackalign/builtin-apply-2.c
@@ -0,0 +1,30 @@
+/* PR target/12503 */
+/* Origin: <pierre.nguyen-tuong@asim.lip6.fr> */
+
+/* Verify that __builtin_apply behaves correctly on targets
+ with pre-pushed arguments (e.g. SPARC). */
+
+/* { dg-do run } */
+
+
+#define INTEGER_ARG 5
+
+extern void abort(void);
+
+void foo(char *name, double d, double e, double f, int g)
+{
+ if (g != INTEGER_ARG)
+ abort();
+}
+
+void bar(char *name, ...)
+{
+ __builtin_apply(foo, __builtin_apply_args(), 64);
+}
+
+int main(void)
+{
+ bar("eeee", 5.444567, 8.90765, 4.567789, INTEGER_ARG);
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/stackalign/builtin-apply-3.c b/gcc/testsuite/gcc.dg/torture/stackalign/builtin-apply-3.c
new file mode 100644
index 000000000..1335d0902
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/stackalign/builtin-apply-3.c
@@ -0,0 +1,31 @@
+/* PR middle-end/12210 */
+/* Origin: Ossadchy Yury A. <waspcoder@mail.ru> */
+
+/* This used to fail on i686 because the argument was not copied
+ to the right location by __builtin_apply after the direct call. */
+
+/* { dg-do run } */
+
+
+#define INTEGER_ARG 5
+
+extern void abort(void);
+
+void foo(int arg)
+{
+ if (arg != INTEGER_ARG)
+ abort();
+}
+
+void bar(int arg)
+{
+ foo(arg);
+ __builtin_apply(foo, __builtin_apply_args(), 16);
+}
+
+int main(void)
+{
+ bar(INTEGER_ARG);
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/stackalign/builtin-apply-4.c b/gcc/testsuite/gcc.dg/torture/stackalign/builtin-apply-4.c
new file mode 100644
index 000000000..28dc6106d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/stackalign/builtin-apply-4.c
@@ -0,0 +1,29 @@
+/* PR tree-optimization/20076 */
+/* { dg-do run } */
+
+extern void abort (void);
+
+double
+foo (int arg)
+{
+ if (arg != 116)
+ abort();
+ return arg + 1;
+}
+
+inline double
+bar (int arg)
+{
+ foo (arg);
+ __builtin_return (__builtin_apply ((void (*) ()) foo,
+ __builtin_apply_args (), 16));
+}
+
+int
+main (int argc, char **argv)
+{
+ if (bar (116) != 117.0)
+ abort ();
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/stackalign/builtin-return-1.c b/gcc/testsuite/gcc.dg/torture/stackalign/builtin-return-1.c
new file mode 100644
index 000000000..75c9acdf7
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/stackalign/builtin-return-1.c
@@ -0,0 +1,34 @@
+/* PR middle-end/11151 */
+/* Originator: Andrew Church <gcczilla@achurch.org> */
+/* { dg-do run } */
+
+/* This used to fail on SPARC because the (undefined) return
+ value of 'bar' was overwriting that of 'foo'. */
+
+extern void abort(void);
+
+int foo(int n)
+{
+ return n+1;
+}
+
+int bar(int n)
+{
+ __builtin_return(__builtin_apply((void (*)(void))foo, __builtin_apply_args(), 64));
+}
+
+char *g;
+
+int main(void)
+{
+ /* Allocate 64 bytes on the stack to make sure that __builtin_apply
+ can read at least 64 bytes above the return address. */
+ char dummy[64];
+
+ g = dummy;
+
+ if (bar(1) != 2)
+ abort();
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/stackalign/check.h b/gcc/testsuite/gcc.dg/torture/stackalign/check.h
new file mode 100644
index 000000000..af1988512
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/stackalign/check.h
@@ -0,0 +1,36 @@
+#include <stddef.h>
+#ifdef DEBUG
+#include <stdio.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" void abort (void);
+#else
+extern void abort (void);
+#endif
+
+int
+check_int (int *i, int align)
+{
+ *i = 20;
+ if ((((ptrdiff_t) i) & (align - 1)) != 0)
+ {
+#ifdef DEBUG
+ printf ("\nUnalign address (%d): %p!\n", align, i);
+#endif
+ abort ();
+ }
+ return *i;
+}
+
+void
+check (void *p, int align)
+{
+ if ((((ptrdiff_t) p) & (align - 1)) != 0)
+ {
+#ifdef DEBUG
+ printf ("\nUnalign address (%d): %p!\n", align, p);
+#endif
+ abort ();
+ }
+}
diff --git a/gcc/testsuite/gcc.dg/torture/stackalign/comp-goto-1.c b/gcc/testsuite/gcc.dg/torture/stackalign/comp-goto-1.c
new file mode 100644
index 000000000..7558f01e2
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/stackalign/comp-goto-1.c
@@ -0,0 +1,41 @@
+/* { dg-do run } */
+
+#ifdef STACK_SIZE
+#define DEPTH ((STACK_SIZE) / 512 + 1)
+#else
+#define DEPTH 1000
+#endif
+
+extern void abort (void);
+extern void exit (int);
+
+#if ! defined (NO_LABEL_VALUES) && !defined (NO_TRAMPOLINES)
+int
+x(a)
+{
+ __label__ xlab;
+ void y(a)
+ {
+ void *x = &&llab;
+ if (a==-1)
+ goto *x;
+ if (a==0)
+ goto xlab;
+ llab:
+ y (a-1);
+ }
+ y (a);
+ xlab:;
+ return a;
+}
+#endif
+
+int
+main ()
+{
+#if ! defined (NO_LABEL_VALUES) && !defined (NO_TRAMPOLINES)
+ if (x (DEPTH) != DEPTH)
+ abort ();
+#endif
+ exit (0);
+}
diff --git a/gcc/testsuite/gcc.dg/torture/stackalign/fastcall-1.c b/gcc/testsuite/gcc.dg/torture/stackalign/fastcall-1.c
new file mode 100644
index 000000000..d1cda1010
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/stackalign/fastcall-1.c
@@ -0,0 +1,31 @@
+/* { dg-do run { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */
+
+#include "check.h"
+
+#ifndef ALIGNMENT
+#define ALIGNMENT 64
+#endif
+
+typedef int aligned __attribute__((aligned(ALIGNMENT)));
+
+int global;
+
+__attribute__ ((fastcall))
+void
+foo (int j, int k, int m, int n, int o)
+{
+ aligned i;
+
+ if (check_int (&i, __alignof__(i)) != i)
+ abort ();
+
+ if (i != 20 || j != 1 || k != 2 || m != 3 || n != 4 || o != 5)
+ abort ();
+}
+
+int
+main()
+{
+ foo (1, 2, 3, 4, 5);
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/stackalign/global-1.c b/gcc/testsuite/gcc.dg/torture/stackalign/global-1.c
new file mode 100644
index 000000000..332103a76
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/stackalign/global-1.c
@@ -0,0 +1,28 @@
+/* { dg-do run } */
+/* { dg-skip-if "Stack alignment is too small" { hppa*-*-hpux* } "*" "" } */
+
+#include "check.h"
+
+#ifndef ALIGNMENT
+#define ALIGNMENT 64
+#endif
+
+typedef int aligned __attribute__((aligned(ALIGNMENT)));
+
+int global;
+
+void
+foo (void)
+{
+ aligned i;
+
+ if (check_int (&i, __alignof__(i)) != i)
+ abort ();
+}
+
+int
+main()
+{
+ foo ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/stackalign/inline-1.c b/gcc/testsuite/gcc.dg/torture/stackalign/inline-1.c
new file mode 100644
index 000000000..38127fd50
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/stackalign/inline-1.c
@@ -0,0 +1,29 @@
+/* { dg-do run } */
+/* { dg-skip-if "Stack alignment is too small" { hppa*-*-hpux* } "*" "" } */
+
+#include "check.h"
+
+#ifndef ALIGNMENT
+#define ALIGNMENT 64
+#endif
+
+typedef int aligned __attribute__((aligned(ALIGNMENT)));
+
+int global;
+
+static void
+inline __attribute__((always_inline))
+foo (void)
+{
+ aligned i;
+
+ if (check_int (&i, __alignof__(i)) != i)
+ abort ();
+}
+
+int
+main()
+{
+ foo ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/stackalign/inline-2.c b/gcc/testsuite/gcc.dg/torture/stackalign/inline-2.c
new file mode 100644
index 000000000..85a2ee3f3
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/stackalign/inline-2.c
@@ -0,0 +1,46 @@
+/* { dg-do run } */
+/* { dg-skip-if "Stack alignment is too small" { hppa*-*-hpux* } "*" "" } */
+
+#include "check.h"
+
+#ifndef ALIGNMENT
+#define ALIGNMENT 64
+#endif
+
+typedef int aligned __attribute__((aligned(ALIGNMENT)));
+
+int global;
+
+void
+bar (char *p, int size)
+{
+ __builtin_strncpy (p, "good", size);
+}
+
+static void
+inline __attribute__((always_inline))
+foo (int size)
+{
+ char *p = __builtin_alloca (size + 1);
+ aligned i;
+
+ bar (p, size);
+ if (__builtin_strncmp (p, "good", size) != 0)
+ {
+#ifdef DEBUG
+ p[size] = '\0';
+ printf ("Failed: %s != good\n", p);
+#endif
+ abort ();
+ }
+
+ if (check_int (&i, __alignof__(i)) != i)
+ abort ();
+}
+
+int
+main()
+{
+ foo (5);
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/stackalign/nested-1.c b/gcc/testsuite/gcc.dg/torture/stackalign/nested-1.c
new file mode 100644
index 000000000..8402f95f5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/stackalign/nested-1.c
@@ -0,0 +1,45 @@
+/* { dg-do run } */
+/* { dg-skip-if "Stack alignment is too small" { hppa*-*-hpux* } "*" "" } */
+
+#include "check.h"
+
+#ifndef ALIGNMENT
+#define ALIGNMENT 64
+#endif
+
+typedef int aligned __attribute__((aligned(ALIGNMENT)));
+
+int global;
+
+void
+foo (void)
+{
+ aligned j;
+
+ void bar ()
+ {
+ aligned i;
+
+ if (check_int (&i, __alignof__(i)) != i)
+ abort ();
+
+ if (check_int (&j, __alignof__(j)) != j)
+ abort ();
+
+ j = -20;
+ }
+ bar ();
+
+ if (j != -20)
+ abort ();
+
+ if (check_int (&j, __alignof__(j)) != j)
+ abort ();
+}
+
+int
+main()
+{
+ foo ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/stackalign/nested-2.c b/gcc/testsuite/gcc.dg/torture/stackalign/nested-2.c
new file mode 100644
index 000000000..dabc310d7
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/stackalign/nested-2.c
@@ -0,0 +1,46 @@
+/* { dg-do run } */
+/* { dg-skip-if "Stack alignment is too small" { hppa*-*-hpux* } "*" "" } */
+
+#include "check.h"
+
+#ifndef ALIGNMENT
+#define ALIGNMENT 64
+#endif
+
+typedef int aligned __attribute__((aligned(ALIGNMENT)));
+
+int global;
+
+void
+foo (void)
+{
+ aligned j;
+
+ __attribute__ ((__noinline__))
+ void bar ()
+ {
+ aligned i;
+
+ if (check_int (&i, __alignof__(i)) != i)
+ abort ();
+
+ if (check_int (&j, __alignof__(j)) != j)
+ abort ();
+
+ j = -20;
+ }
+ bar ();
+
+ if (j != -20)
+ abort ();
+
+ if (check_int (&j, __alignof__(j)) != j)
+ abort ();
+}
+
+int
+main()
+{
+ foo ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/stackalign/nested-3.c b/gcc/testsuite/gcc.dg/torture/stackalign/nested-3.c
new file mode 100644
index 000000000..d35c9a7ce
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/stackalign/nested-3.c
@@ -0,0 +1,63 @@
+/* { dg-do run } */
+/* { dg-skip-if "Stack alignment is too small" { hppa*-*-hpux* } "*" "" } */
+
+#include "check.h"
+
+#ifndef ALIGNMENT
+#define ALIGNMENT 64
+#endif
+
+typedef int aligned __attribute__((aligned(ALIGNMENT)));
+
+int global;
+
+void
+copy (char *p, int size)
+{
+ __builtin_strncpy (p, "good", size);
+}
+
+void
+foo (int size)
+{
+ aligned j;
+
+ __attribute__ ((__noinline__))
+ void bar (int size)
+ {
+ char *p = __builtin_alloca (size + 1);
+ aligned i;
+
+ copy (p, size);
+ if (strncmp (p, "good", size) != 0)
+ {
+#ifdef DEBUG
+ p[size] = '\0';
+ printf ("Failed: %s != good\n", p);
+#endif
+ abort ();
+ }
+
+ if (check_int (&i, __alignof__(i)) != i)
+ abort ();
+
+ if (check_int (&j, __alignof__(j)) != j)
+ abort ();
+
+ j = -20;
+ }
+ bar (size);
+
+ if (j != -20)
+ abort ();
+
+ if (check_int (&j, __alignof__(j)) != j)
+ abort ();
+}
+
+int
+main()
+{
+ foo (5);
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/stackalign/nested-4.c b/gcc/testsuite/gcc.dg/torture/stackalign/nested-4.c
new file mode 100644
index 000000000..05cb83301
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/stackalign/nested-4.c
@@ -0,0 +1,34 @@
+/* { dg-do run } */
+/* { dg-skip-if "Stack alignment is too small" { hppa*-*-hpux* } "*" "" } */
+
+#include "check.h"
+
+#ifndef ALIGNMENT
+#define ALIGNMENT 64
+#endif
+
+typedef int aligned __attribute__((aligned(ALIGNMENT)));
+
+int n;
+
+void
+g (void)
+{
+ __label__ lab;
+ void h (void)
+ {
+ aligned t;
+ if (check_int (&t, __alignof__(t)) != t)
+ abort ();
+ if (n+t == 0) goto lab;
+ }
+ h();
+lab:
+ return;
+}
+
+int main()
+{
+ g();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/stackalign/nested-5.c b/gcc/testsuite/gcc.dg/torture/stackalign/nested-5.c
new file mode 100644
index 000000000..95eba0482
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/stackalign/nested-5.c
@@ -0,0 +1,38 @@
+/* { dg-do run } */
+
+extern void abort (void);
+extern void exit (int);
+
+#ifndef NO_TRAMPOLINES
+static void recursive (int n, void (*proc) (void))
+{
+ __label__ l1;
+
+ void do_goto (void)
+ {
+ goto l1;
+ }
+
+ if (n == 3)
+ recursive (n - 1, do_goto);
+ else if (n > 0)
+ recursive (n - 1, proc);
+ else
+ (*proc) ();
+ return;
+
+l1:
+ if (n == 3)
+ exit (0);
+ else
+ abort ();
+}
+
+int main ()
+{
+ recursive (10, abort);
+ abort ();
+}
+#else
+int main () { return 0; }
+#endif
diff --git a/gcc/testsuite/gcc.dg/torture/stackalign/nested-6.c b/gcc/testsuite/gcc.dg/torture/stackalign/nested-6.c
new file mode 100644
index 000000000..d853825fe
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/stackalign/nested-6.c
@@ -0,0 +1,28 @@
+/* { dg-do run } */
+
+#ifndef NO_TRAMPOLINES
+
+typedef __SIZE_TYPE__ size_t;
+extern void abort (void);
+extern void exit (int);
+extern void qsort(void *, size_t, size_t, int (*)(const void *, const void *));
+
+int main ()
+{
+ __label__ nonlocal;
+ int compare (const void *a, const void *b)
+ {
+ goto nonlocal;
+ }
+
+ char array[3];
+ qsort (array, 3, 1, compare);
+ abort ();
+
+ nonlocal:
+ exit (0);
+}
+
+#else
+int main() { return 0; }
+#endif
diff --git a/gcc/testsuite/gcc.dg/torture/stackalign/non-local-goto-1.c b/gcc/testsuite/gcc.dg/torture/stackalign/non-local-goto-1.c
new file mode 100644
index 000000000..263d4486c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/stackalign/non-local-goto-1.c
@@ -0,0 +1,55 @@
+/* { dg-do run } */
+
+extern void abort (void);
+
+int global;
+
+static void foo(void) __attribute__((noinline));
+
+static void foo(void)
+{
+ global = 1;
+}
+
+static void bar(void)
+{
+ foo ();
+}
+
+int execute(int cmd)
+{
+ __label__ start;
+
+ void raise(void)
+ {
+ goto start;
+ }
+
+ int last = -1;
+
+ bar ();
+
+ last = 0;
+
+start:
+
+ if (last == 0)
+ while (1)
+ {
+ last = 1;
+ raise ();
+ }
+
+ if (last == 0)
+ return 0;
+ else
+ return cmd;
+}
+
+int main(void)
+{
+ if (execute (1) == 0)
+ abort ();
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/stackalign/non-local-goto-2.c b/gcc/testsuite/gcc.dg/torture/stackalign/non-local-goto-2.c
new file mode 100644
index 000000000..5a64d5419
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/stackalign/non-local-goto-2.c
@@ -0,0 +1,56 @@
+/* { dg-do run } */
+
+extern void abort (void);
+
+int global;
+
+static void foo(void) __attribute__((noinline));
+
+static void foo(void)
+{
+ global = 1;
+}
+
+static void bar(void)
+{
+ foo ();
+ global = 0;
+}
+
+int execute(int cmd)
+{
+ __label__ start;
+
+ void raise(void)
+ {
+ goto start;
+ }
+
+ int last = -1;
+
+ bar ();
+
+ last = 0;
+
+start:
+
+ if (last == 0)
+ while (1)
+ {
+ last = 1;
+ raise ();
+ }
+
+ if (last == 0)
+ return 0;
+ else
+ return cmd;
+}
+
+int main(void)
+{
+ if (execute (1) == 0)
+ abort ();
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/stackalign/non-local-goto-3.c b/gcc/testsuite/gcc.dg/torture/stackalign/non-local-goto-3.c
new file mode 100644
index 000000000..3afc8cc6a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/stackalign/non-local-goto-3.c
@@ -0,0 +1,42 @@
+/* { dg-do run } */
+
+#ifndef NO_TRAMPOLINES
+extern void abort (void);
+
+int x(int a, int b)
+{
+ __label__ xlab;
+
+ void y(int b)
+ {
+ switch (b)
+ {
+ case 1: goto xlab;
+ case 2: goto xlab;
+ }
+ }
+
+ a = a + 2;
+ y (b);
+
+ xlab:
+ return a;
+}
+
+int main ()
+{
+ int i, j;
+
+ for (j = 1; j <= 2; ++j)
+ for (i = 1; i <= 2; ++i)
+ {
+ int a = x (j, i);
+ if (a != 2 + j)
+ abort ();
+ }
+
+ return 0;
+}
+#else
+int main() { return 0; }
+#endif
diff --git a/gcc/testsuite/gcc.dg/torture/stackalign/non-local-goto-4.c b/gcc/testsuite/gcc.dg/torture/stackalign/non-local-goto-4.c
new file mode 100644
index 000000000..3673f1ac3
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/stackalign/non-local-goto-4.c
@@ -0,0 +1,38 @@
+/* { dg-do run } */
+
+extern void abort (void);
+extern void exit (int);
+
+#ifdef STACK_SIZE
+#define DEPTH ((STACK_SIZE) / 512 + 1)
+#else
+#define DEPTH 1000
+#endif
+
+#if ! defined (NO_LABEL_VALUES) && !defined (NO_TRAMPOLINES)
+int
+
+x(a)
+{
+ __label__ xlab;
+ void y(a)
+ {
+ if (a==0)
+ goto xlab;
+ y (a-1);
+ }
+ y (a);
+ xlab:;
+ return a;
+}
+#endif
+
+int
+main ()
+{
+#if ! defined (NO_LABEL_VALUES) && !defined (NO_TRAMPOLINES)
+ if (x (DEPTH) != DEPTH)
+ abort ();
+#endif
+ exit (0);
+}
diff --git a/gcc/testsuite/gcc.dg/torture/stackalign/non-local-goto-5.c b/gcc/testsuite/gcc.dg/torture/stackalign/non-local-goto-5.c
new file mode 100644
index 000000000..d198c9a97
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/stackalign/non-local-goto-5.c
@@ -0,0 +1,11 @@
+/* { dg-do run } */
+
+extern void exit (int);
+#if !defined (NO_LABEL_VALUES) && !defined (NO_TRAMPOLINES)
+extern void abort (void);
+int s(i){if(i>0){__label__ l1;int f(int i){if(i==2)goto l1;return 0;}return f(i);l1:;}return 1;}
+int x(){return s(0)==1&&s(1)==0&&s(2)==1;}
+int main(){if(x()!=1)abort();exit(0);}
+#else
+int main(){ exit (0); }
+#endif
diff --git a/gcc/testsuite/gcc.dg/torture/stackalign/pr16660-1.c b/gcc/testsuite/gcc.dg/torture/stackalign/pr16660-1.c
new file mode 100644
index 000000000..b917e824b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/stackalign/pr16660-1.c
@@ -0,0 +1,18 @@
+/* { dg-do run } */
+/* { dg-skip-if "Stack alignment is too small" { hppa*-*-hpux* } "*" "" } */
+
+#include "check.h"
+
+void
+f ()
+{
+ unsigned long tmp[4] __attribute__((aligned(64)));
+ check (&tmp, 64);
+}
+
+int
+main()
+{
+ f();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/stackalign/pr16660-2.c b/gcc/testsuite/gcc.dg/torture/stackalign/pr16660-2.c
new file mode 100644
index 000000000..9a039eb2b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/stackalign/pr16660-2.c
@@ -0,0 +1,12 @@
+/* { dg-do run } */
+
+#include "check.h"
+
+typedef __SIZE_TYPE__ size_t;
+#define ALIGNMENT 256
+int main(void)
+{
+ int a[ALIGNMENT/sizeof(int)] __attribute__((aligned(ALIGNMENT)));
+ check (&a, ALIGNMENT);
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/stackalign/pr16660-3.c b/gcc/testsuite/gcc.dg/torture/stackalign/pr16660-3.c
new file mode 100644
index 000000000..1c1ddd1dd
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/stackalign/pr16660-3.c
@@ -0,0 +1,14 @@
+/* { dg-do run } */
+
+#include "check.h"
+
+typedef __SIZE_TYPE__ size_t;
+#define ALIGNMENT 256
+int main(void)
+{
+ int a[ALIGNMENT/sizeof(int)] __attribute__((aligned(ALIGNMENT)));
+ check (&a, ALIGNMENT);
+ int b[ALIGNMENT/sizeof(int)] __attribute__((aligned(ALIGNMENT)));
+ check (&b, ALIGNMENT);
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/stackalign/push-1.c b/gcc/testsuite/gcc.dg/torture/stackalign/push-1.c
new file mode 100644
index 000000000..dd5dffc15
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/stackalign/push-1.c
@@ -0,0 +1,51 @@
+/* PR middle-end/37010 */
+/* { dg-do run { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */
+/* { dg-options "-msse2 -mpreferred-stack-boundary=2" } */
+/* { dg-require-effective-target sse2_runtime } */
+
+#include <emmintrin.h>
+
+typedef __PTRDIFF_TYPE__ ptrdiff_t;
+typedef float __m128 __attribute__ ((__vector_size__ (16), __may_alias__));
+typedef int aligned __attribute__((aligned(16)));
+
+extern void abort (void);
+
+__m128 r;
+
+int
+__attribute__ ((noinline))
+check_int (int *i, int align)
+{
+ *i = 20;
+ if ((((ptrdiff_t) i) & (align - 1)) != 0)
+ {
+ abort ();
+ }
+ return *i;
+}
+
+void
+__attribute__ ((noinline))
+foo (__m128 x, __m128 y ,__m128 z ,__m128 a, int size)
+{
+ aligned i;
+
+ if (size != 5 || check_int (&i, __alignof__(i)) != i)
+ abort ();
+
+ r = a;
+}
+
+int
+main (void)
+{
+ __m128 x = { 1.0 };
+
+ foo (x, x, x, x, 5);
+
+ if (__builtin_memcmp (&r, &x, sizeof (r)))
+ abort ();
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/stackalign/regparm-1.c b/gcc/testsuite/gcc.dg/torture/stackalign/regparm-1.c
new file mode 100644
index 000000000..9dac024cc
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/stackalign/regparm-1.c
@@ -0,0 +1,60 @@
+/* { dg-do run { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */
+
+#include "check.h"
+
+#ifndef ALIGNMENT
+#define ALIGNMENT 64
+#endif
+
+typedef int aligned __attribute__((aligned(ALIGNMENT)));
+
+int test_nested (int i)
+{
+ aligned y;
+
+ int __attribute__ ((__noinline__, __regparm__(2))) foo (int j, int k, int l)
+ {
+ aligned x;
+
+ if (check_int (&x, __alignof__(x)) != x)
+ abort ();
+
+ if (x != 20)
+ abort ();
+
+ return i + j + k + l;
+ }
+
+ if (check_int (&y, __alignof__(y)) != y)
+ abort ();
+
+ if (y != 20)
+ abort ();
+
+ return foo(i, i+1, i+2) * i;
+}
+
+int __attribute__ ((__noinline__, __regparm__(3), __force_align_arg_pointer__))
+test_realigned (int j, int k, int l)
+{
+ aligned y;
+
+ if (check_int (&y, __alignof__(y)) != y)
+ abort ();
+
+ if (y != 20)
+ abort ();
+
+ return j + k + l;
+}
+
+int main ()
+{
+ if (test_nested(10) != 430)
+ abort ();
+
+ if (test_realigned(10, 11, 12) != 33)
+ abort ();
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/stackalign/ret-struct-1.c b/gcc/testsuite/gcc.dg/torture/stackalign/ret-struct-1.c
new file mode 100644
index 000000000..b218a14ed
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/stackalign/ret-struct-1.c
@@ -0,0 +1,36 @@
+/* { dg-do run } */
+/* { dg-skip-if "Stack alignment is too small" { hppa*-*-hpux* } "*" "" } */
+
+#include "check.h"
+
+#ifndef ALIGNMENT
+#define ALIGNMENT 64
+#endif
+
+extern void abort();
+typedef struct my_struct
+{
+ char str[31];
+} stype ;
+
+stype g_s;
+
+stype __attribute__((noinline))
+foo (char arg1, char arg2, char arg3)
+{
+ stype __attribute__((aligned(ALIGNMENT))) s;
+ s.str[0] = arg1;
+ s.str[1] = arg2;
+ s.str[30] = arg3;
+ check(&s, ALIGNMENT);
+ return s;
+}
+
+int main()
+{
+ g_s = foo(1,2,3);
+
+ if (g_s.str[0] != 1 || g_s.str[1] != 2 || g_s.str[30] !=3)
+ abort();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/stackalign/setjmp-1.c b/gcc/testsuite/gcc.dg/torture/stackalign/setjmp-1.c
new file mode 100644
index 000000000..6ab67e395
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/stackalign/setjmp-1.c
@@ -0,0 +1,43 @@
+/* { dg-do run } */
+
+extern int strcmp(const char *, const char *);
+extern char *strcpy(char *, const char *);
+extern void abort(void);
+extern void exit(int);
+
+void *buf[20];
+
+void __attribute__((noinline))
+sub2 (void)
+{
+ __builtin_longjmp (buf, 1);
+}
+
+int
+main ()
+{
+ char *p = 0;
+
+ p = (char *) __builtin_alloca (20);
+
+ strcpy (p, "test");
+
+ if (__builtin_setjmp (buf))
+ {
+ if (strcmp (p, "test") != 0)
+ abort ();
+
+ exit (0);
+ }
+
+ {
+ int *q = (int *) __builtin_alloca (p[2] * sizeof (int));
+ int i;
+
+ for (i = 0; i < p[2]; i++)
+ q[i] = 0;
+
+ while (1)
+ sub2 ();
+ }
+}
diff --git a/gcc/testsuite/gcc.dg/torture/stackalign/setjmp-2.c b/gcc/testsuite/gcc.dg/torture/stackalign/setjmp-2.c
new file mode 100644
index 000000000..c93ffa867
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/stackalign/setjmp-2.c
@@ -0,0 +1,46 @@
+/* { dg-do run { target i?86-*-linux* x86_64-*-linux* } } */
+
+#include <setjmp.h>
+#include <signal.h>
+
+#ifndef NULL
+#define NULL ((void *)0)
+#endif
+static jmp_buf segv_jmpbuf;
+
+static void segv_handler(int seg)
+{
+ __builtin_longjmp(segv_jmpbuf, 1);
+}
+
+static int is_addressable(void *p, size_t size)
+{
+ volatile char * volatile cp = (volatile char *)p;
+ volatile int ret;
+ struct sigaction sa, origsa;
+ sigset_t mask;
+
+ sa.sa_handler = segv_handler;
+ sa.sa_flags = 0;
+ sigfillset(&sa.sa_mask);
+ sigaction(SIGSEGV, &sa, &origsa);
+ sigprocmask(SIG_SETMASK, NULL, &mask);
+
+ if (__builtin_setjmp(segv_jmpbuf) == 0) {
+ while(size--)
+ *cp++;
+ ret = 1;
+ } else
+ ret = 0;
+
+ sigaction(SIGSEGV, &origsa, NULL);
+ sigprocmask(SIG_SETMASK, &mask, NULL);
+
+ return ret;
+}
+
+int main(int argc, char **argv)
+{
+ is_addressable(0x0, 1);
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/stackalign/setjmp-3.c b/gcc/testsuite/gcc.dg/torture/stackalign/setjmp-3.c
new file mode 100644
index 000000000..fee0d281f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/stackalign/setjmp-3.c
@@ -0,0 +1,37 @@
+/* { dg-do run } */
+
+#include <setjmp.h>
+
+extern void abort (void);
+
+jmp_buf buf;
+
+void raise0(void)
+{
+ __builtin_longjmp (buf, 1);
+}
+
+int execute(int cmd)
+{
+ int last = 0;
+
+ if (__builtin_setjmp (buf) == 0)
+ while (1)
+ {
+ last = 1;
+ raise0 ();
+ }
+
+ if (last == 0)
+ return 0;
+ else
+ return cmd;
+}
+
+int main(void)
+{
+ if (execute (1) == 0)
+ abort ();
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/stackalign/setjmp-4.c b/gcc/testsuite/gcc.dg/torture/stackalign/setjmp-4.c
new file mode 100644
index 000000000..d1671223a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/stackalign/setjmp-4.c
@@ -0,0 +1,39 @@
+/* { dg-do run } */
+
+#include <setjmp.h>
+
+extern void abort (void);
+
+jmp_buf buf;
+
+void raise0(void)
+{
+ __builtin_longjmp (buf, 1);
+}
+
+int execute(int cmd)
+{
+ int last = 0;
+
+ __builtin_setjmp (buf);
+
+ if (last == 0)
+ while (1)
+ {
+ last = 1;
+ raise0 ();
+ }
+
+ if (last == 0)
+ return 0;
+ else
+ return cmd;
+}
+
+int main(void)
+{
+ if (execute (1) == 0)
+ abort ();
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/stackalign/sibcall-1.c b/gcc/testsuite/gcc.dg/torture/stackalign/sibcall-1.c
new file mode 100644
index 000000000..8c174758f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/stackalign/sibcall-1.c
@@ -0,0 +1,35 @@
+/* { dg-do run } */
+
+extern int ok (int);
+extern void exit ();
+static int gen_x86_64_shrd (int);
+static int
+gen_x86_64_shrd(int a __attribute__ ((__unused__)))
+{
+ return 0;
+}
+
+extern int gen_x86_shrd_1 (int);
+extern void ix86_split_ashr (int);
+
+void
+ix86_split_ashr (int mode)
+{
+ (mode != 0
+ ? ok
+ : gen_x86_64_shrd) (0);
+}
+
+volatile int one = 1;
+int
+main (void)
+{
+ ix86_split_ashr (one);
+ return 1;
+}
+
+int
+ok (int i)
+{
+ exit (i);
+}
diff --git a/gcc/testsuite/gcc.dg/torture/stackalign/stackalign.exp b/gcc/testsuite/gcc.dg/torture/stackalign/stackalign.exp
new file mode 100644
index 000000000..a975c6b52
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/stackalign/stackalign.exp
@@ -0,0 +1,50 @@
+# Copyright (C) 2008, 2010
+# Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3. If not see
+# <http://www.gnu.org/licenses/>.
+
+# This harness is for tests that should be run at all optimisation levels.
+
+load_lib gcc-dg.exp
+
+set additional_flags ""
+if { [check_effective_target_automatic_stack_alignment] } then {
+ lappend additional_flags "-mstackrealign"
+ lappend additional_flags "-mpreferred-stack-boundary=5"
+}
+if { [istarget i?86*-*-*] || [istarget x86_64-*-*] } then {
+ lappend additional_flags "-mno-mmx"
+}
+
+dg-init
+
+gcc-dg-runtest [lsort [glob $srcdir/$subdir/*.c]] $additional_flags
+if { [check_effective_target_fpic] } then {
+ set pic_additional_flags $additional_flags
+ lappend pic_additional_flags "-fpic"
+ gcc-dg-runtest [lsort [glob $srcdir/$subdir/*.c]] $pic_additional_flags
+}
+
+if { [check_effective_target_automatic_stack_alignment] } then {
+ lappend additional_flags "-mforce-drap"
+ gcc-dg-runtest [lsort [glob $srcdir/$subdir/*.c]] $additional_flags
+ if { [check_effective_target_fpic] } then {
+ set pic_additional_flags $additional_flags
+ lappend pic_additional_flags "-fpic"
+ gcc-dg-runtest [lsort [glob $srcdir/$subdir/*.c]] $pic_additional_flags
+ }
+}
+
+dg-finish
diff --git a/gcc/testsuite/gcc.dg/torture/stackalign/struct-1.c b/gcc/testsuite/gcc.dg/torture/stackalign/struct-1.c
new file mode 100644
index 000000000..860213298
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/stackalign/struct-1.c
@@ -0,0 +1,29 @@
+/* { dg-do run } */
+/* { dg-skip-if "Stack alignment is too small" { hppa*-*-hpux* } "*" "" } */
+
+#include "check.h"
+
+#ifndef ALIGNMENT
+#define ALIGNMENT 64
+#endif
+
+typedef int aligned __attribute__((aligned(ALIGNMENT)));
+
+void
+foo (void)
+{
+ struct i
+ {
+ aligned i;
+ } i;
+
+ if (check_int (&i.i, __alignof__(i.i)) != i.i)
+ abort ();
+}
+
+int
+main()
+{
+ foo ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/stackalign/thiscall-1.c b/gcc/testsuite/gcc.dg/torture/stackalign/thiscall-1.c
new file mode 100644
index 000000000..6f22e07e3
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/stackalign/thiscall-1.c
@@ -0,0 +1,31 @@
+/* { dg-do run { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */
+
+#include "check.h"
+
+#ifndef ALIGNMENT
+#define ALIGNMENT 64
+#endif
+
+typedef int aligned __attribute__((aligned(ALIGNMENT)));
+
+int global;
+
+__attribute__ ((thiscall))
+void
+foo (int j, int k, int m, int n, int o)
+{
+ aligned i;
+
+ if (check_int (&i, __alignof__(i)) != i)
+ abort ();
+
+ if (i != 20 || j != 1 || k != 2 || m != 3 || n != 4 || o != 5)
+ abort ();
+}
+
+int
+main()
+{
+ foo (1, 2, 3, 4, 5);
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/stackalign/vararg-1.c b/gcc/testsuite/gcc.dg/torture/stackalign/vararg-1.c
new file mode 100644
index 000000000..5b36f2cd4
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/stackalign/vararg-1.c
@@ -0,0 +1,60 @@
+/* { dg-do run } */
+/* { dg-skip-if "Stack alignment is too small" { hppa*-*-hpux* } "*" "" } */
+
+#include <stdarg.h>
+#include "check.h"
+
+#ifndef ALIGNMENT
+#define ALIGNMENT 64
+#endif
+
+typedef int aligned __attribute__((aligned(ALIGNMENT)));
+
+int global;
+
+void
+bar (char *p, int size)
+{
+ __builtin_strncpy (p, "good", size);
+}
+
+void
+foo (const char *fmt, ...)
+{
+ va_list arg;
+ char *p;
+ aligned i;
+ int size;
+ double x;
+
+ va_start (arg, fmt);
+ size = va_arg (arg, int);
+ if (size != 5)
+ abort ();
+ p = __builtin_alloca (size + 1);
+
+ x = va_arg (arg, double);
+ if (x != 5.0)
+ abort ();
+
+ bar (p, size);
+ if (__builtin_strncmp (p, "good", size) != 0)
+ {
+#ifdef DEBUG
+ p[size] = '\0';
+ printf ("Failed: %s != good\n", p);
+#endif
+ abort ();
+ }
+
+ if (check_int (&i, __alignof__(i)) != i)
+ abort ();
+ va_end (arg);
+}
+
+int
+main()
+{
+ foo ("foo", 5, 5.0);
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/stackalign/vararg-2.c b/gcc/testsuite/gcc.dg/torture/stackalign/vararg-2.c
new file mode 100644
index 000000000..6740e994e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/stackalign/vararg-2.c
@@ -0,0 +1,66 @@
+/* { dg-do run } */
+/* { dg-skip-if "Stack alignment is too small" { hppa*-*-hpux* } "*" "" } */
+
+#include <stdarg.h>
+#include "check.h"
+
+#ifndef ALIGNMENT
+#define ALIGNMENT 64
+#endif
+
+typedef int aligned __attribute__((aligned(ALIGNMENT)));
+
+int global;
+
+void
+bar (char *p, int size)
+{
+ __builtin_strncpy (p, "good", size);
+}
+
+void
+test (va_list arg)
+{
+ char *p;
+ aligned i;
+ int size;
+ double x;
+
+ size = va_arg (arg, int);
+ if (size != 5)
+ abort ();
+
+ p = __builtin_alloca (size + 1);
+
+ x = va_arg (arg, double);
+ if (x != 5.0)
+ abort ();
+
+ bar (p, size);
+ if (__builtin_strncmp (p, "good", size) != 0)
+ {
+#ifdef DEBUG
+ p[size] = '\0';
+ printf ("Failed: %s != good\n", p);
+#endif
+ abort ();
+ }
+
+ if (check_int (&i, __alignof__(i)) != i)
+ abort ();
+}
+
+void
+foo (const char *fmt, ...)
+{
+ va_list arg;
+ va_start (arg, fmt);
+ test (arg);
+ va_end (arg);
+}
+int
+main()
+{
+ foo ("foo", 5, 5.0);
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/stackalign/vararg-3.c b/gcc/testsuite/gcc.dg/torture/stackalign/vararg-3.c
new file mode 100644
index 000000000..5b49685fa
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/stackalign/vararg-3.c
@@ -0,0 +1,78 @@
+/* PR middle-end/37009 */
+/* { dg-do run { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */
+/* { dg-options "-msse2" } */
+/* { dg-require-effective-target sse2_runtime } */
+
+#include <stdarg.h>
+#include <emmintrin.h>
+#include "check.h"
+
+#ifndef ALIGNMENT
+#define ALIGNMENT 16
+#endif
+
+typedef int aligned __attribute__((aligned(ALIGNMENT)));
+
+void
+bar (char *p, int size)
+{
+ __builtin_strncpy (p, "good", size);
+}
+
+__m128 a = { 1.0 };
+
+void
+test (va_list arg)
+{
+ char *p;
+ aligned i;
+ int size;
+ double x;
+ __m128 e;
+
+ size = va_arg (arg, int);
+ if (size != 5)
+ abort ();
+
+ p = __builtin_alloca (size + 1);
+
+ x = va_arg (arg, double);
+ if (x != 5.0)
+ abort ();
+
+ bar (p, size);
+ if (__builtin_strncmp (p, "good", size) != 0)
+ {
+#ifdef DEBUG
+ p[size] = '\0';
+ printf ("Failed: %s != good\n", p);
+#endif
+ abort ();
+ }
+
+ if (check_int (&i, __alignof__(i)) != i)
+ abort ();
+
+ e = va_arg (arg, __m128);
+ if (__builtin_memcmp (&e, &a, sizeof (e)))
+ abort ();
+}
+
+void
+foo (const char *fmt, ...)
+{
+ va_list arg;
+ va_start (arg, fmt);
+ test (arg);
+ va_end (arg);
+}
+
+int
+main (void)
+{
+ __m128 x = { 1.0 };
+
+ foo ("foo", 5, 5.0, x);
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/tls/thr-init-1.c b/gcc/testsuite/gcc.dg/torture/tls/thr-init-1.c
new file mode 100644
index 000000000..ff3338ffb
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/tls/thr-init-1.c
@@ -0,0 +1,26 @@
+/* { dg-do run } */
+/* { dg-require-effective-target tls_runtime } */
+/* { dg-add-options tls } */
+
+extern int printf (char *,...);
+extern void abort() ;
+
+int test_code(int b)
+{
+static __thread int fstat = 1;
+ fstat += b ;
+ return fstat;
+}
+
+int main (int ac, char *av[])
+{
+ int a = test_code(1);
+
+ if ( a != 2 )
+ {
+ printf ("a=%d\n", a) ;
+ abort ();
+ }
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/tls/thr-init-2.c b/gcc/testsuite/gcc.dg/torture/tls/thr-init-2.c
new file mode 100644
index 000000000..44156232c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/tls/thr-init-2.c
@@ -0,0 +1,29 @@
+/* { dg-do run } */
+/* { dg-require-effective-target tls_runtime } */
+/* { dg-add-options tls } */
+
+extern int printf (char *,...);
+extern void abort() ;
+
+static __thread int fstat ;
+static __thread int fstat = 1;
+static __thread int fstat ;
+
+int test_code(int b)
+{
+ fstat += b ;
+ return fstat;
+}
+
+int main (int ac, char *av[])
+{
+ int a = test_code(1);
+
+ if ( a != 2 || fstat != 2 )
+ {
+ printf ("a=%d fstat=%d\n", a, fstat) ;
+ abort ();
+ }
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/tls/tls-test.c b/gcc/testsuite/gcc.dg/torture/tls/tls-test.c
new file mode 100644
index 000000000..8a23e77c1
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/tls/tls-test.c
@@ -0,0 +1,52 @@
+/* { dg-do run } */
+/* { dg-require-effective-target tls } */
+/* { dg-require-effective-target pthread } */
+/* { dg-options "-pthread" } */
+
+#include <pthread.h>
+extern int printf (char *,...);
+__thread int a = 5;
+int *volatile a_in_other_thread = (int *) 12345;
+
+static void *
+thread_func (void *arg)
+{
+ a_in_other_thread = &a;
+ a+=5;
+ *((int *) arg) = a;
+ return (void *)0;
+}
+
+int
+main ()
+{
+ pthread_t thread;
+ void *thread_retval;
+ int *volatile a_in_main_thread;
+ int *volatile again ;
+ int thr_a;
+
+ a_in_main_thread = &a;
+
+ if (pthread_create (&thread, (pthread_attr_t *)0, thread_func, &thr_a))
+ return 0;
+
+ if (pthread_join (thread, &thread_retval))
+ return 0;
+
+ again = &a;
+ if (again != a_in_main_thread)
+ {
+ printf ("FAIL: main thread addy changed from 0x%0x to 0x%0x\n",
+ a_in_other_thread, again);
+ return 1;
+ }
+
+ if (a != 5 || thr_a != 10 || (a_in_other_thread == a_in_main_thread))
+ {
+ printf ("FAIL: a= %d, thr_a = %d Addr = 0x%0x\n",
+ a, thr_a, a_in_other_thread);
+ return 1;
+ }
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/tls/tls.exp b/gcc/testsuite/gcc.dg/torture/tls/tls.exp
new file mode 100644
index 000000000..91c8843c4
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/tls/tls.exp
@@ -0,0 +1,36 @@
+# Copyright (C) 2010 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3. If not see
+# <http://www.gnu.org/licenses/>.
+
+# GCC testsuite that uses the `dg.exp' driver.
+
+# Load support procs.
+load_lib gcc-dg.exp
+
+# If a testcase doesn't have special options, use these.
+global DEFAULT_CFLAGS
+if ![info exists DEFAULT_CFLAGS] then {
+ set DEFAULT_CFLAGS " -ansi -pedantic-errors"
+}
+
+# Initialize `dg'.
+dg-init
+
+# Main loop.
+gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] \
+ $DEFAULT_CFLAGS
+
+# All done.
+dg-finish
diff --git a/gcc/testsuite/gcc.dg/torture/tree-loop-1.c b/gcc/testsuite/gcc.dg/torture/tree-loop-1.c
new file mode 100644
index 000000000..1d3869178
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/tree-loop-1.c
@@ -0,0 +1,21 @@
+/* PR tree-optimization/20640 */
+
+/* After unrolling the loop, we'd turn some conditional branches into
+ unconditional ones, but branch redirection would fail to compute
+ the PHI args for the PHI nodes in the replacement edge
+ destination, so they'd remain NULL causing crashes later on. */
+
+/* { dg-do compile } */
+
+static int a = 0;
+extern int foo (void);
+extern int *bar (void) __attribute__ ((__const__));
+
+void
+test (int x)
+{
+ int b = 10;
+ while (foo () == -1 && *bar () == 4 && b > 0)
+ --b;
+ a = x;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/type-generic-1.c b/gcc/testsuite/gcc.dg/torture/type-generic-1.c
new file mode 100644
index 000000000..add83c098
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/type-generic-1.c
@@ -0,0 +1,13 @@
+/* Do the type-generic tests. Unlike pr28796-2.c, we test these
+ without any fast-math flags. */
+
+/* { dg-do run } */
+/* { dg-skip-if "No Inf/NaN support" { spu-*-* } } */
+/* { dg-add-options ieee } */
+
+#include "../tg-tests.h"
+
+int main(void)
+{
+ return main_tests ();
+}
diff --git a/gcc/testsuite/gcc.dg/torture/va-arg-25.c b/gcc/testsuite/gcc.dg/torture/va-arg-25.c
new file mode 100644
index 000000000..8c0da549d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/va-arg-25.c
@@ -0,0 +1,44 @@
+/* Varargs and vectors! */
+
+/* { dg-do run } */
+/* { dg-options "-msse" { target { i?86-*-* x86_64-*-* } } } */
+/* { dg-require-effective-target sse_runtime { target { i?86-*-* x86_64-*-* } } } */
+/* { dg-options "-mabi=altivec -maltivec" { target { powerpc-*-* powerpc64-*-* } } } */
+/* { dg-require-effective-target vmx_hw { target { powerpc-*-* powerpc64--*-* } } } */
+
+#include <stdarg.h>
+#include <stdlib.h>
+#include <limits.h>
+
+#define vector __attribute__((vector_size(16)))
+
+const vector unsigned int v1 = {10,11,12,13};
+const vector unsigned int v2 = {20,21,22,23};
+
+void foo(int a, ...)
+{
+ va_list args;
+ vector unsigned int v;
+
+ va_start (args, a);
+ v = va_arg (args, vector unsigned int);
+ if (a != 1 || memcmp (&v, &v1, sizeof (v)) != 0)
+ abort ();
+ a = va_arg (args, int);
+ if (a != 2)
+ abort ();
+ v = va_arg (args, vector unsigned int);
+ if (memcmp (&v, &v2, sizeof (v)) != 0)
+ abort ();
+ va_end (args);
+}
+
+int main(void)
+{
+#if INT_MAX == 2147483647
+ foo (1, (vector unsigned int){10,11,12,13}, 2,
+ (vector unsigned int){20,21,22,23});
+#endif
+ return 0;
+}
+
diff --git a/gcc/testsuite/gcc.dg/torture/vector-1.c b/gcc/testsuite/gcc.dg/torture/vector-1.c
new file mode 100644
index 000000000..205fee6d6
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/vector-1.c
@@ -0,0 +1,42 @@
+/* Check that vector extraction works correctly. */
+
+/* { dg-do run } */
+/* { dg-options "-msse" { target { i?86-*-* x86_64-*-* } } } */
+/* { dg-require-effective-target sse_runtime { target { i?86-*-* x86_64-*-* } } } */
+/* { dg-options "-mabi=altivec" { target { powerpc-*-* powerpc64-*-* } } } */
+/* { dg-require-effective-target vmx_hw { target { powerpc-*-* powerpc64--*-* } } } */
+
+#define vector __attribute__((vector_size(16) ))
+
+int f0(vector int t)
+{
+ return ((int*)&t)[0];
+}
+int f1(vector int t)
+{
+ return ((int*)&t)[1];
+}
+int f2(vector int t)
+{
+ return ((int*)&t)[2];
+}
+int f3(vector int t)
+{
+ return ((int*)&t)[3];
+}
+int main(void)
+{
+ vector int a = {0, 1, 2, 3};
+ /* Make sure that we have the correct size for the vectors. */
+ if (sizeof(int) != 4)
+ __builtin_exit (0);
+ if (f0(a) != 0)
+ __builtin_abort ();
+ if (f1(a) != 1)
+ __builtin_abort ();
+ if (f2(a) != 2)
+ __builtin_abort ();
+ if (f3(a) != 3)
+ __builtin_abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/vector-2.c b/gcc/testsuite/gcc.dg/torture/vector-2.c
new file mode 100644
index 000000000..6cc56cfae
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/vector-2.c
@@ -0,0 +1,52 @@
+/* Check that vector insertion works correctly. */
+
+/* { dg-do run } */
+/* { dg-options "-msse" { target { i?86-*-* x86_64-*-* } } } */
+/* { dg-require-effective-target sse_runtime { target { i?86-*-* x86_64-*-* } } } */
+/* { dg-options "-mabi=altivec" { target { powerpc-*-* powerpc64-*-* } } } */
+/* { dg-require-effective-target vmx_hw { target { powerpc-*-* powerpc64--*-* } } } */
+
+#define vector __attribute__((vector_size(16) ))
+
+vector int f0(vector int t, int a)
+{
+ ((int*)&t)[0] = a;
+ return t;
+}
+vector int f1(vector int t, int a)
+{
+ ((int*)&t)[1] = a;
+ return t;
+}
+vector int f2(vector int t, int a)
+{
+ ((int*)&t)[2] = a;
+ return t;
+}
+vector int f3(vector int t, int a)
+{
+ ((int*)&t)[3] = a;
+ return t;
+}
+int main(void)
+{
+ vector int a = {0, 0, 0, 0};
+ vector int b = {1, 0, 0, 0};
+ vector int c = {0, 1, 0, 0};
+ vector int d = {0, 0, 1, 0};
+ vector int e = {0, 0, 0, 1};
+ vector int a0;
+ a0 = f0(a, 1);
+ if (memcmp (&a0, &b, sizeof(a0)))
+ __builtin_abort ();
+ a0 = f1(a, 1);
+ if (memcmp (&a0, &c, sizeof(a0)))
+ __builtin_abort ();
+ a0 = f2(a, 1);
+ if (memcmp (&a0, &d, sizeof(a0)))
+ __builtin_abort ();
+ a0 = f3(a, 1);
+ if (memcmp (&a0, &e, sizeof(a0)))
+ __builtin_abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/vector-shift2.c b/gcc/testsuite/gcc.dg/torture/vector-shift2.c
new file mode 100644
index 000000000..0e8a0eb24
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/vector-shift2.c
@@ -0,0 +1,61 @@
+/* { dg-do run } */
+
+#define vector(elcount, type) \
+__attribute__((vector_size((elcount)*sizeof(type)))) type
+
+#define vidx(type, vec, idx) (*((type *) &(vec) + idx))
+#define schar signed char
+#define uchar unsigned char
+
+#define ch14 1,2,3,4
+#define ch1 1,1,1,1
+#define chm1 -1,-1,-1,-1
+
+int main (int argc, char *argv[]) {
+ vector(16, uchar) vuchar = { ch14, ch14, ch14, ch14};
+ vector(16, schar) vchar0 = { ch1, ch1, ch1, ch1};
+ vector(16, schar) vchar1 = { chm1, chm1, chm1, chm1};
+
+ vector(16, schar) i1, i2, i3;
+ vector(16, uchar) u1, u2, u3;
+
+ i1 = vchar1<< vchar0;
+
+ if (vidx(schar, i1, 0) != ((schar)-1 << (schar)1))
+ __builtin_abort ();
+ if (vidx(schar, i1, 1) != ((schar)-1 << (schar)1))
+ __builtin_abort ();
+ if (vidx(schar, i1, 2) != ((schar)-1 << (schar)1))
+ __builtin_abort ();
+ if (vidx(schar, i1, 3) != ((schar)-1 << (schar)1))
+ __builtin_abort ();
+ u1 = vuchar << vchar0;
+
+ if (vidx(uchar, u1, 0) != ((uchar)1 << (schar)1))
+ __builtin_abort ();
+ if (vidx(uchar, u1, 1) != ((uchar)2 << (schar)1))
+ __builtin_abort ();
+ if (vidx(uchar, u1, 2) != ((uchar)3 << (schar)1))
+ __builtin_abort ();
+ if (vidx(uchar, u1, 3) != ((uchar)4 << (schar)1))
+ __builtin_abort ();
+
+
+ i2 = vchar1 >> vuchar;
+
+ if (vidx(schar, i2, 0) != ((schar)-1 >> (uchar)1))
+ __builtin_abort ();
+ if (vidx(schar, i2, 1) != ((schar)-1 >> (uchar)2))
+ __builtin_abort ();
+ if (vidx(schar, i2, 2) != ((schar)-1 >> (uchar)3))
+ __builtin_abort ();
+ if (vidx(schar, i2, 3) != ((schar)-1 >> (uchar)4))
+ __builtin_abort ();
+
+ vchar1 >>= vuchar;
+ vuchar <<= vchar0;
+ vuchar <<= vchar1;
+
+ return 0;
+}
+