comparison src/share/vm/opto/memnode.cpp @ 624:337400e7a5dd

6797305: Add LoadUB and LoadUI opcode class Summary: Add a LoadUB (unsigned byte) and LoadUI (unsigned int) opcode class so we have these load optimizations in the first place and do not need to handle them in the matcher. Reviewed-by: never, kvn
author twisti
date Mon, 09 Mar 2009 03:17:11 -0700
parents 98cb887364d3
children 7bb995fbd3c0
comparison
equal deleted inserted replaced
623:9adddb8c0fc8 624:337400e7a5dd
1 /* 1 /*
2 * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved. 2 * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
776 "use LoadKlassNode instead"); 776 "use LoadKlassNode instead");
777 assert(!(adr_type->isa_aryptr() && 777 assert(!(adr_type->isa_aryptr() &&
778 adr_type->offset() == arrayOopDesc::length_offset_in_bytes()), 778 adr_type->offset() == arrayOopDesc::length_offset_in_bytes()),
779 "use LoadRangeNode instead"); 779 "use LoadRangeNode instead");
780 switch (bt) { 780 switch (bt) {
781 case T_BOOLEAN: 781 case T_BOOLEAN: return new (C, 3) LoadUBNode(ctl, mem, adr, adr_type, rt->is_int() );
782 case T_BYTE: return new (C, 3) LoadBNode (ctl, mem, adr, adr_type, rt->is_int() ); 782 case T_BYTE: return new (C, 3) LoadBNode (ctl, mem, adr, adr_type, rt->is_int() );
783 case T_INT: return new (C, 3) LoadINode (ctl, mem, adr, adr_type, rt->is_int() ); 783 case T_INT: return new (C, 3) LoadINode (ctl, mem, adr, adr_type, rt->is_int() );
784 case T_CHAR: return new (C, 3) LoadUSNode(ctl, mem, adr, adr_type, rt->is_int() ); 784 case T_CHAR: return new (C, 3) LoadUSNode(ctl, mem, adr, adr_type, rt->is_int() );
785 case T_SHORT: return new (C, 3) LoadSNode (ctl, mem, adr, adr_type, rt->is_int() ); 785 case T_SHORT: return new (C, 3) LoadSNode (ctl, mem, adr, adr_type, rt->is_int() );
786 case T_LONG: return new (C, 3) LoadLNode (ctl, mem, adr, adr_type, rt->is_long() ); 786 case T_LONG: return new (C, 3) LoadLNode (ctl, mem, adr, adr_type, rt->is_long() );
1614 } 1614 }
1615 // Identity call will handle the case where truncation is not needed. 1615 // Identity call will handle the case where truncation is not needed.
1616 return LoadNode::Ideal(phase, can_reshape); 1616 return LoadNode::Ideal(phase, can_reshape);
1617 } 1617 }
1618 1618
1619 //--------------------------LoadUBNode::Ideal-------------------------------------
1620 //
1621 // If the previous store is to the same address as this load,
1622 // and the value stored was larger than a byte, replace this load
1623 // with the value stored truncated to a byte. If no truncation is
1624 // needed, the replacement is done in LoadNode::Identity().
1625 //
1626 Node* LoadUBNode::Ideal(PhaseGVN* phase, bool can_reshape) {
1627 Node* mem = in(MemNode::Memory);
1628 Node* value = can_see_stored_value(mem, phase);
1629 if (value && !phase->type(value)->higher_equal(_type))
1630 return new (phase->C, 3) AndINode(value, phase->intcon(0xFF));
1631 // Identity call will handle the case where truncation is not needed.
1632 return LoadNode::Ideal(phase, can_reshape);
1633 }
1634
1619 //--------------------------LoadUSNode::Ideal------------------------------------- 1635 //--------------------------LoadUSNode::Ideal-------------------------------------
1620 // 1636 //
1621 // If the previous store is to the same address as this load, 1637 // If the previous store is to the same address as this load,
1622 // and the value stored was larger than a char, replace this load 1638 // and the value stored was larger than a char, replace this load
1623 // with the value stored truncated to a char. If no truncation is 1639 // with the value stored truncated to a char. If no truncation is