diff options
author | Reid Barton <rwbarton@gmail.com> | 2017-03-23 21:02:29 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2017-03-24 10:14:26 -0400 |
commit | caf94b062a0e37ffa7048e51447fc9486b658917 (patch) | |
tree | d14fdcbcbdf3844ae80dbe423396d825974bbe4e /testsuite/tests/codeGen | |
parent | 8429a202ec8aef0af226d3fb5907b47dc9cba155 (diff) | |
download | haskell-caf94b062a0e37ffa7048e51447fc9486b658917.tar.gz |
x86 nativeGen: Fix test with mask in range [128,255] (#13425)
My commit bdb0c43c7 optimized the encoding of instructions to test
tag bits, but it did not always set exactly the same condition codes
since the testb instruction does a single-byte comparison, rather
than a full-word comparison.
It would be correct to optimize the expression `x .&. 128 > 0` to
the sequence
testb $128, %al
seta %al ; note: 'a' for unsigned comparison,
; not 'g' for signed comparison
but the pretty-printer is not the right place to make this kind of
context-sensitive optimization.
Test Plan: harbormaster
Reviewers: trofi, austin, bgamari, dfeuer
Reviewed By: trofi, dfeuer
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D3359
Diffstat (limited to 'testsuite/tests/codeGen')
-rw-r--r-- | testsuite/tests/codeGen/should_run/T13425.hs | 10 | ||||
-rw-r--r-- | testsuite/tests/codeGen/should_run/T13425.stdout | 1 | ||||
-rw-r--r-- | testsuite/tests/codeGen/should_run/all.T | 1 |
3 files changed, 12 insertions, 0 deletions
diff --git a/testsuite/tests/codeGen/should_run/T13425.hs b/testsuite/tests/codeGen/should_run/T13425.hs new file mode 100644 index 0000000000..49d07211cc --- /dev/null +++ b/testsuite/tests/codeGen/should_run/T13425.hs @@ -0,0 +1,10 @@ +import Data.Bits ((.&.)) + +flags :: Int -> Int +flags x + | x .&. 128 > 0 = 12 + | otherwise = 13 +{-# NOINLINE flags #-} + +main :: IO () +main = print (flags 255) diff --git a/testsuite/tests/codeGen/should_run/T13425.stdout b/testsuite/tests/codeGen/should_run/T13425.stdout new file mode 100644 index 0000000000..48082f72f0 --- /dev/null +++ b/testsuite/tests/codeGen/should_run/T13425.stdout @@ -0,0 +1 @@ +12 diff --git a/testsuite/tests/codeGen/should_run/all.T b/testsuite/tests/codeGen/should_run/all.T index b952c10dc4..ffe4b64cbe 100644 --- a/testsuite/tests/codeGen/should_run/all.T +++ b/testsuite/tests/codeGen/should_run/all.T @@ -155,3 +155,4 @@ test('T9577', [ unless(arch('x86_64') or arch('i386'),skip), when(opsys('darwin'), expect_broken(12937)), when(opsys('mingw32'), expect_broken(12965)), only_ways(['normal']) ], compile_and_run, ['']) +test('T13425', normal, compile_and_run, ['-O']) |