summaryrefslogtreecommitdiffstats
path: root/lldb/packages/Python/lldbsuite/test/python_api/frame/main.c
diff options
context:
space:
mode:
authorRoman Lebedev <lebedev.ri@gmail.com>2018-06-06 19:38:27 +0000
committerRoman Lebedev <lebedev.ri@gmail.com>2018-06-06 19:38:27 +0000
commitcbf8446359a226466efb12ad0e1dbc66a3afe592 (patch)
treee11cae33512a97012de523ef3c0f3f9b064a6acc /lldb/packages/Python/lldbsuite/test/python_api/frame/main.c
parent4771bc6c3581e5988e827ca3722753483d715f85 (diff)
downloadbcm5719-llvm-cbf8446359a226466efb12ad0e1dbc66a3afe592.tar.gz
bcm5719-llvm-cbf8446359a226466efb12ad0e1dbc66a3afe592.zip
[InstCombine] PR37603: low bit mask canonicalization
Summary: This is [[ https://bugs.llvm.org/show_bug.cgi?id=37603 | PR37603 ]]. https://godbolt.org/g/VCMNpS https://rise4fun.com/Alive/idM When doing bit manipulations, it is quite common to calculate some bit mask, and apply it to some value via `and`. The typical C code looks like: ``` int mask_signed_add(int nbits) { return (1 << nbits) - 1; } ``` which is translated into (with `-O3`) ``` define dso_local i32 @mask_signed_add(int)(i32) local_unnamed_addr #0 { %2 = shl i32 1, %0 %3 = add nsw i32 %2, -1 ret i32 %3 } ``` But there is a second, less readable variant: ``` int mask_signed_xor(int nbits) { return ~(-(1 << nbits)); } ``` which is translated into (with `-O3`) ``` define dso_local i32 @mask_signed_xor(int)(i32) local_unnamed_addr #0 { %2 = shl i32 -1, %0 %3 = xor i32 %2, -1 ret i32 %3 } ``` Since we created such a mask, it is quite likely that we will use it in `and` next. And then we may get rid of `not` op by folding into `andn`. But now that i have actually looked: https://godbolt.org/g/VTUDmU _some_ backend changes will be needed too. We clearly loose `bzhi` recognition. Reviewers: spatel, craig.topper, RKSimon Reviewed By: spatel Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D47428 llvm-svn: 334127
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/python_api/frame/main.c')
0 files changed, 0 insertions, 0 deletions
OpenPOWER on IntegriCloud