Commit Graph

12 Commits

Author SHA1 Message Date
Roman Levenstein
f8a1aaff96 [sil-simplify] Add a peephole for XOR
Use the following equality: (x xor y) xor y == x.
With this in mind (a xor b) xor c can be replaced by:
 a - if b and c are the same
 b - if a and c are the same
 c - if a and b are the same

rdar://20280322

Swift SVN r26568
2015-03-26 00:37:08 +00:00
Michael Gottesman
6f8b468cb6 Change switches and selects to use NullablePtr<EnumElementDecl> instead of EnumElementDecl * when their API explicitly requires the user to check for nullptr. NFC.
This is just good to do and hopefully will help prevent people from forgetting
to check in the future by annotating the API explicitly as returning a
potentially nullptr.

Swift SVN r25364
2015-02-18 02:11:57 +00:00
Luqman Aden
c3c3c8af76 [InstSimplifier] Do simple peephole optimzations for
ThinFunctionToPointerInst and PointerToThinFunctionInst.

(thin_function_to_pointer (pointer_to_thin_function x)) -> x
(pointer_to_thin_function (thin_function_pointer x)) -> x

Fixes <rdar://problem/19285047>

Swift SVN r24652
2015-01-22 20:06:43 +00:00
Michael Gottesman
53cf98c001 Have computeSignBit in ValueTracking look through AND/OR/XOR operands.
Patch by Luqman Aden!
Fixes <rdar://problem/18758859>

Swift SVN r24590
2015-01-21 04:34:43 +00:00
Erik Eckstein
da9f08aec8 Replace the default-entry with a corresponding case-entry in select_enum[ _addr], if possible.
This is exactly the same thing as I did for switch_enum.



Swift SVN r23116
2014-11-05 12:48:11 +00:00
Michael Gottesman
3f36560266 [simplify-inst] Simplify ref <=> unowned and ref <=> unmanaged round trips.
This happens a lot in DeltaBlue.

rdar://18759413

Swift SVN r22920
2014-10-24 20:26:32 +00:00
Joe Groff
e3f9a2035c SIL: Move SILGen and passes over to use "builtin" instead of "apply (builtin_function_ref)".
Swift SVN r22785
2014-10-15 23:37:22 +00:00
Arnold Schwaighofer
90440fd139 InstSimplifier: Simplify select_enum instructions
Swift SVN r22714
2014-10-14 01:18:49 +00:00
Mark Lacey
4402ebfaa2 Fix enum instruction simplification.
When simplifying an 'enum' instruction that appears in a block that is
the destination of a switch_enum, we need to ensure that the block with
the 'enum' instruction is uniquely chosen based on the same enum tag
that the 'enum' instruction uses, not just that we'll reach that
destination block with the same enum tag (since we could have multiple
tags target the same block, and could have a default case).

Fixes rdar://problem/18330952.

Swift SVN r22065
2014-09-18 08:53:58 +00:00
Roman Levenstein
a81a99776f Improve optimization of builtin operations that may overflow. Remove overflow checks if it can be proven that no overflow can happen.
Swift SVN r21874
2014-09-11 16:00:54 +00:00
Roman Levenstein
2470f035e7 code-cleanup: Use SILValue.getType() instead of SILValue->getType(0)
Swift SVN r21770
2014-09-08 09:52:37 +00:00
Michael Gottesman
6e485700c6 Move SimplifyInstruction into SILAnalysis since it is an analysis.
This will hopefully make it clearer as we onboard people that
SimplifyInstruction should not add instructions to the IR by making it clearer
that it is an analysis, not a pass.

Swift SVN r21752
2014-09-05 22:56:26 +00:00