mirror of
				https://github.com/c64scene-ar/llvm-6502.git
				synced 2025-11-03 14:21:30 +00:00 
			
		
		
		
	InstCombine: fold (sitofp (zext x)) to (uitofp x)
This is okay because the zext guarantees the high bit is zero, and so the value is unsigned. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235364 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
		@@ -2118,7 +2118,7 @@ unsigned CastInst::isEliminableCastPair(
 | 
				
			|||||||
    // N  X  X  U  S  F  F  N  X  N  2  V  V   |
 | 
					    // N  X  X  U  S  F  F  N  X  N  2  V  V   |
 | 
				
			||||||
    // C  T  T  I  I  P  P  C  T  T  P  T  T  -+
 | 
					    // C  T  T  I  I  P  P  C  T  T  P  T  T  -+
 | 
				
			||||||
    {  1, 0, 0,99,99, 0, 0,99,99,99, 0, 3, 0}, // Trunc         -+
 | 
					    {  1, 0, 0,99,99, 0, 0,99,99,99, 0, 3, 0}, // Trunc         -+
 | 
				
			||||||
    {  8, 1, 9,99,99, 2, 0,99,99,99, 2, 3, 0}, // ZExt           |
 | 
					    {  8, 1, 9,99,99, 2,17,99,99,99, 2, 3, 0}, // ZExt           |
 | 
				
			||||||
    {  8, 0, 1,99,99, 0, 2,99,99,99, 0, 3, 0}, // SExt           |
 | 
					    {  8, 0, 1,99,99, 0, 2,99,99,99, 0, 3, 0}, // SExt           |
 | 
				
			||||||
    {  0, 0, 0,99,99, 0, 0,99,99,99, 0, 3, 0}, // FPToUI         |
 | 
					    {  0, 0, 0,99,99, 0, 0,99,99,99, 0, 3, 0}, // FPToUI         |
 | 
				
			||||||
    {  0, 0, 0,99,99, 0, 0,99,99,99, 0, 3, 0}, // FPToSI         |
 | 
					    {  0, 0, 0,99,99, 0, 0,99,99,99, 0, 3, 0}, // FPToSI         |
 | 
				
			||||||
@@ -2285,6 +2285,9 @@ unsigned CastInst::isEliminableCastPair(
 | 
				
			|||||||
        "Illegal bitcast, ptrtoint sequence!");
 | 
					        "Illegal bitcast, ptrtoint sequence!");
 | 
				
			||||||
      // Allowed, use second cast's opcode
 | 
					      // Allowed, use second cast's opcode
 | 
				
			||||||
      return secondOp;
 | 
					      return secondOp;
 | 
				
			||||||
 | 
					    case 17:
 | 
				
			||||||
 | 
					      // (sitofp (zext x)) -> (uitofp x)
 | 
				
			||||||
 | 
					      return Instruction::UIToFP;
 | 
				
			||||||
    case 99: 
 | 
					    case 99: 
 | 
				
			||||||
      // Cast combination can't happen (error in input). This is for all cases
 | 
					      // Cast combination can't happen (error in input). This is for all cases
 | 
				
			||||||
      // where the MidTy is not the same for the two cast instructions.
 | 
					      // where the MidTy is not the same for the two cast instructions.
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1104,3 +1104,12 @@ define i32 @PR21388(i32* %v) {
 | 
				
			|||||||
; CHECK-NEXT: %[[sext:.*]] = sext i1 %[[icmp]] to i32
 | 
					; CHECK-NEXT: %[[sext:.*]] = sext i1 %[[icmp]] to i32
 | 
				
			||||||
; CHECK-NEXT: ret i32 %[[sext]]
 | 
					; CHECK-NEXT: ret i32 %[[sext]]
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					define float @sitofp_zext(i16 %a) {
 | 
				
			||||||
 | 
					; CHECK-LABEL: @sitofp_zext(
 | 
				
			||||||
 | 
					; CHECK-NEXT: %[[sitofp:.*]] = uitofp i16 %a to float
 | 
				
			||||||
 | 
					; CHECK-NEXT: ret float %[[sitofp]]
 | 
				
			||||||
 | 
					  %zext = zext i16 %a to i32
 | 
				
			||||||
 | 
					  %sitofp = sitofp i32 %zext to float
 | 
				
			||||||
 | 
					  ret float %sitofp
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user