2005-09-23  Aldy Hernandez  <aldyh@redhat.com>

	* combine.c (simplify_comparison): Disable zero_extend combination
	when making paradoxical subregs.

	* config/mn10300/mn10300.md: Remove movbu truncation hack from all
	relevant patterns.

Index: combine.c
===================================================================
RCS file: /cvs/cvsfiles/gnupro/gcc/combine.c,v
retrieving revision 1.7
diff -c -p -r1.7 combine.c
*** combine.c	16 Sep 2004 21:42:58 -0000	1.7
--- combine.c	23 Sep 2005 16:20:57 -0000
*************** simplify_comparison (enum rtx_code code,
*** 10739,10744 ****
--- 10739,10768 ----
  	      && ((unsigned HOST_WIDE_INT) const_op
  		  < GET_MODE_MASK (GET_MODE (XEXP (op0, 0)))))
  	    {
+ 	       /* Issue 78925: The code below will cause a nonsensical paradoxical
+ 	          subreg to be created.  This subreg will cause problems in reload
+ 	          because it will fail to realize that the subreg implied a
+ 	          zero_extend.  
+ 
+ 		  Specifically, we would transform:
+ 			(zero_extend:SI (mem:QI blah) ...
+ 		  into
+ 			(subreg:SI (mem:QI ...
+ 
+ 		  Later reload would replace the mem:QI by a register, and
+ 		  eventually the subreg would be disregarded by just replacing
+ 		  (reg:QI) by (reg:SI).
+ 
+ 		  Disabling the code below will fix:
+ 
+ 		      gcc.c-torture/execute/20030128-1.c
+ 
+ 	          Mainline does not suffer from this bug, as it was fixed by the
+ 	          tree-ssa merge.
+ 	       */
+ 	       if (GET_CODE (op0) == ZERO_EXTEND)
+ 	         break;
+ 
  	      op0 = XEXP (op0, 0);
  	      continue;
  	    }
Index: config/mn10300/mn10300.md
===================================================================
RCS file: /cvs/cvsfiles/gnupro/gcc/config/mn10300/mn10300.md,v
retrieving revision 1.8.8.3.2.3
diff -c -p -r1.8.8.3.2.3 mn10300.md
*** config/mn10300/mn10300.md	5 Aug 2005 14:40:20 -0000	1.8.8.3.2.3
--- config/mn10300/mn10300.md	23 Sep 2005 16:20:58 -0000
***************
*** 105,118 ****
      case 3:
        return \"movbu %1,%0\";
      case 4:
!       if (optimize == 1)
!         /* This is a hack.  Compiling gcc.c-torture/execute/20030128-1.c
! 	   will fail because reload thinks that the movbu has truncated
! 	   the register contents as well.  Only fixed in mainline by the
! 	   tree-ssa merge.  */
!         return \"movbu %1,%0; extbu %1\";
!       else
!         return \"movbu %1,%0\";	
      case 5:
      case 6:
        return \"fmov %1,%0\";
--- 105,111 ----
      case 3:
        return \"movbu %1,%0\";
      case 4:
!       return \"movbu %1,%0\";	
      case 5:
      case 6:
        return \"fmov %1,%0\";
***************
*** 149,162 ****
      case 3:
        return \"movbu %1,%0\";
      case 4:
!       if (optimize == 1)
!         /* This is a hack.  Compiling gcc.c-torture/execute/20030128-1.c
! 	   will fail because reload thinks that the movbu has truncated
! 	   the register contents as well.  Only fixed in mainline by the
! 	   tree-ssa merge.  */
!         return \"movbu %1,%0; extbu %1\";
!       else
!         return \"movbu %1,%0\";	
      default:
        abort ();
      }
--- 142,148 ----
      case 3:
        return \"movbu %1,%0\";
      case 4:
!       return \"movbu %1,%0\";	
      default:
        abort ();
      }
***************
*** 214,227 ****
      case 3:
        return \"movhu %1,%0\";
      case 4:
!       if (optimize == 1)
!         /* This is a hack.  Compiling gcc.c-torture/execute/20000528-1.c
! 	   will fail because reload thinks that the movhu has truncated
! 	   the register contents as well.  Only fixed in mainline by the
! 	   tree-ssa merge.  */
!         return \"movhu %1,%0; exthu %1\";
!       else
!         return \"movhu %1,%0\";	
      case 5:
      case 6:
        return \"fmov %1,%0\";
--- 200,206 ----
      case 3:
        return \"movhu %1,%0\";
      case 4:
!       return \"movhu %1,%0\";	
      case 5:
      case 6:
        return \"fmov %1,%0\";
***************
*** 257,270 ****
      case 3:
          return \"movhu %1,%0\";
      case 4:
!       if (optimize == 1)
!         /* This is a hack.  Compiling gcc.c-torture/execute/20000528-1.c
! 	   will fail because reload thinks that the movhu has truncated
! 	   the register contents as well.  Only fixed in mainline by the
! 	   tree-ssa merge.  */
!         return \"movhu %1,%0; exthu %1\";
!       else
!         return \"movhu %1,%0\";	
      default:
        abort ();
      }
--- 236,242 ----
      case 3:
          return \"movhu %1,%0\";
      case 4:
!       return \"movhu %1,%0\";	
      default:
        abort ();
      }
