mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-13 08:26:02 +00:00
Transform this:
%X = alloca ... %Y = alloca ... X == Y into false. This allows us to simplify some stuff in eon (and probably many other C++ programs) where operator= was checking for self assignment. Folding this allows us to SROA several additional structs. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17735 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -1870,12 +1870,14 @@ Instruction *InstCombiner::visitSetCondInst(BinaryOperator &I) {
|
|||||||
if (isa<UndefValue>(Op1)) // X setcc undef -> undef
|
if (isa<UndefValue>(Op1)) // X setcc undef -> undef
|
||||||
return ReplaceInstUsesWith(I, UndefValue::get(Type::BoolTy));
|
return ReplaceInstUsesWith(I, UndefValue::get(Type::BoolTy));
|
||||||
|
|
||||||
// setcc <global/alloca*>, 0 - Global/Stack value addresses are never null!
|
// setcc <global/alloca*/null>, <global/alloca*/null> - Global/Stack value
|
||||||
if (isa<ConstantPointerNull>(Op1) &&
|
// addresses never equal each other! We already know that Op0 != Op1.
|
||||||
(isa<GlobalValue>(Op0) || isa<AllocaInst>(Op0)))
|
if ((isa<GlobalValue>(Op0) || isa<AllocaInst>(Op0) ||
|
||||||
|
isa<ConstantPointerNull>(Op0)) &&
|
||||||
|
(isa<GlobalValue>(Op1) || isa<AllocaInst>(Op1) ||
|
||||||
|
isa<ConstantPointerNull>(Op1)))
|
||||||
return ReplaceInstUsesWith(I, ConstantBool::get(!isTrueWhenEqual(I)));
|
return ReplaceInstUsesWith(I, ConstantBool::get(!isTrueWhenEqual(I)));
|
||||||
|
|
||||||
|
|
||||||
// setcc's with boolean values can always be turned into bitwise operations
|
// setcc's with boolean values can always be turned into bitwise operations
|
||||||
if (Ty == Type::BoolTy) {
|
if (Ty == Type::BoolTy) {
|
||||||
switch (I.getOpcode()) {
|
switch (I.getOpcode()) {
|
||||||
|
Reference in New Issue
Block a user