1; RUN: llc < %s -march=x86 | FileCheck %s 2 3; When doing sign extension, use the sext-load lowering to take advantage of 4; x86's sign extension during loads. 5; 6; CHECK-LABEL: test1: 7; CHECK: movsbl {{.*}}, %eax 8; CHECK-NEXT: ret 9define i32 @test1(i32 %X) nounwind { 10entry: 11 %tmp12 = trunc i32 %X to i8 ; <i8> [#uses=1] 12 %tmp123 = sext i8 %tmp12 to i32 ; <i32> [#uses=1] 13 ret i32 %tmp123 14} 15 16; When using a sextload representation, ensure that the sign extension is 17; preserved even when removing shifted-out low bits. 18; 19; CHECK-LABEL: test2: 20; CHECK: movswl {{.*}}, %eax 21; CHECK-NEXT: ret 22define i32 @test2({i16, [6 x i8]}* %this) { 23entry: 24 %b48 = getelementptr inbounds { i16, [6 x i8] }, { i16, [6 x i8] }* %this, i32 0, i32 1 25 %cast = bitcast [6 x i8]* %b48 to i48* 26 %bf.load = load i48, i48* %cast, align 2 27 %bf.ashr = ashr i48 %bf.load, 32 28 %bf.cast = trunc i48 %bf.ashr to i32 29 ret i32 %bf.cast 30} 31