Skip to content

cmd/compile: arm comparisons with 0 incorrect on overflow #39303

@randall77

Description

@randall77

Comparisons like if x+10 < 0 branch incorrectly if the x+10 overflows.
This was found and fixed for arm64, see #38740, CL 233097. The test in that CL also fails on arm, so the same fix needs to happen for arm.

--- FAIL: TestCondRewrite (0.01s)
    --- FAIL: TestCondRewrite/AddConst32 (0.00s)
        rewriteCond_test.go:120: '0x7ffffffd + 11 < 0' failed
        rewriteCond_test.go:125: '0x7ffffffd + 13 <= 0' failed
        rewriteCond_test.go:130: '-0x7fffffff - 11 > 0' failed
        rewriteCond_test.go:135: '-0x7fffffff - 13 >= 0' failed
        rewriteCond_test.go:139: '0x7ffffffd + 19 > 0' failed
        rewriteCond_test.go:143: '0x7ffffffd + 23 >= 0' failed
        rewriteCond_test.go:147: '-0x7fffffff - 19 < 0' failed
        rewriteCond_test.go:151: '-0x7fffffff - 23 <= 0' failed
    --- FAIL: TestCondRewrite/AddVar32 (0.00s)
        rewriteCond_test.go:198: '0x7ffffffd + 0xb < 0' failed
        rewriteCond_test.go:203: '0x7ffffffd + 0xb <= 0' failed
        rewriteCond_test.go:208: '-0x7fffffff + -0xb > 0' failed
        rewriteCond_test.go:213: '-0x7fffffff + -0xb >= 0' failed
        rewriteCond_test.go:217: '0x7ffffffd + 0xb > 0' failed
        rewriteCond_test.go:221: '0x7ffffffd + 0xb >= 0' failed
        rewriteCond_test.go:225: '-0x7fffffff + -0xb < 0' failed
        rewriteCond_test.go:229: '-0x7fffffff + -0xb <= 0' failed
    --- FAIL: TestCondRewrite/MAddVar32 (0.00s)
        rewriteCond_test.go:276: '0x7ffffffd + 0xb*1 < 0' failed
        rewriteCond_test.go:281: '0x7ffffffd + 0xb*1 <= 0' failed
        rewriteCond_test.go:286: '-0x7fffffff + -0xb*1 > 0' failed
        rewriteCond_test.go:291: '-0x7fffffff + -0xb*1 >= 0' failed
        rewriteCond_test.go:295: '0x7ffffffd + 0xb*1 > 0' failed
        rewriteCond_test.go:299: '0x7ffffffd + 0xb*1 >= 0' failed
        rewriteCond_test.go:303: '-0x7fffffff + -0xb*1 < 0' failed
        rewriteCond_test.go:307: '-0x7fffffff + -0xb*1 <= 0' failed
    --- FAIL: TestCondRewrite/MSubVar32 (0.00s)
        rewriteCond_test.go:363: '0x7ffffffd - -0xb*1 < 0' failed
        rewriteCond_test.go:368: '0x7ffffffd - -0xb*1 <= 0' failed
        rewriteCond_test.go:373: '-0x7fffffff - 0xb*1 > 0' failed
        rewriteCond_test.go:378: '-0x7fffffff - 0xb*1 >= 0' failed
        rewriteCond_test.go:382: '0x7ffffffd - -0xb*1 > 0' failed
        rewriteCond_test.go:386: '0x7ffffffd - -0xb*1 >= 0' failed
        rewriteCond_test.go:390: '-0x7fffffff - 0xb*1 < 0' failed
        rewriteCond_test.go:394: '-0x7fffffff - 0xb*1 <= 0' failed

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.okay-after-beta1Used by release team to mark a release-blocker issue as okay to resolve either before or after beta1release-blocker

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions