summaryrefslogtreecommitdiffstats
path: root/llvm/test
diff options
context:
space:
mode:
authorQuentin Colombet <qcolombet@apple.com>2014-12-22 18:11:52 +0000
committerQuentin Colombet <qcolombet@apple.com>2014-12-22 18:11:52 +0000
commit84f89ccd4517557781c8277a5045bb85a2cdd238 (patch)
treefac5149d8d93960595f1b4323891b207ef56c131 /llvm/test
parent4f371b031b17b8d6bdf35b18e63753a95c69d825 (diff)
downloadbcm5719-llvm-84f89ccd4517557781c8277a5045bb85a2cdd238.tar.gz
bcm5719-llvm-84f89ccd4517557781c8277a5045bb85a2cdd238.zip
[CodeGenPrepare] Handle properly the promotion of operands when this does not
generate instructions. Fixes PR21978. Related to <rdar://problem/18310086> llvm-svn: 224717
Diffstat (limited to 'llvm/test')
-rw-r--r--llvm/test/CodeGen/X86/codegen-prepare-extload.ll25
1 files changed, 25 insertions, 0 deletions
diff --git a/llvm/test/CodeGen/X86/codegen-prepare-extload.ll b/llvm/test/CodeGen/X86/codegen-prepare-extload.ll
index f607a6f3569..9b27c33a80f 100644
--- a/llvm/test/CodeGen/X86/codegen-prepare-extload.ll
+++ b/llvm/test/CodeGen/X86/codegen-prepare-extload.ll
@@ -336,3 +336,28 @@ entry:
%b = zext <2 x i32> %a to <2 x i64>
ret void
}
+
+@a = common global i32 0, align 4
+@c = common global [2 x i32] zeroinitializer, align 4
+
+; PR21978.
+; Make sure we support promotion of operands that produces a Value as opposed
+; to an instruction.
+; This used to cause a crash.
+; OPTALL-LABEL: @promotionOfArgEndsUpInValue
+; OPTALL: [[LD:%[a-zA-Z_0-9-]+]] = load i16* %addr
+
+; OPT-NEXT: [[SEXT:%[a-zA-Z_0-9-]+]] = sext i16 [[LD]] to i32
+; OPT-NEXT: [[RES:%[a-zA-Z_0-9-]+]] = add nuw nsw i32 [[SEXT]], zext (i1 icmp ne (i32* getelementptr inbounds ([2 x i32]* @c, i64 0, i64 1), i32* @a) to i32)
+;
+; DISABLE-NEXT: [[ADD:%[a-zA-Z_0-9-]+]] = add nuw nsw i16 [[LD]], zext (i1 icmp ne (i32* getelementptr inbounds ([2 x i32]* @c, i64 0, i64 1), i32* @a) to i16)
+; DISABLE-NEXT: [[RES:%[a-zA-Z_0-9-]+]] = sext i16 [[ADD]] to i32
+;
+; OPTALL-NEXT: ret i32 [[RES]]
+define i32 @promotionOfArgEndsUpInValue(i16* %addr) {
+entry:
+ %val = load i16* %addr
+ %add = add nuw nsw i16 %val, zext (i1 icmp ne (i32* getelementptr inbounds ([2 x i32]* @c, i64 0, i64 1), i32* @a) to i16)
+ %conv3 = sext i16 %add to i32
+ ret i32 %conv3
+}
OpenPOWER on IntegriCloud