This should always be signed chars, so use int8_t. This fixes a miscompile when
authorNick Lewycky <nicholas@mxc.ca>
Wed, 20 Apr 2011 03:19:42 +0000 (03:19 +0000)
committerNick Lewycky <nicholas@mxc.ca>
Wed, 20 Apr 2011 03:19:42 +0000 (03:19 +0000)
llvm is built with unsigned chars where an immediate such as 0xff would be zero
extended to 64-bits, turning "cmp $0xff,%eax" into
"cmp $0xffffffffffffffff,%eax".

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129845 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/X86InstrInfo.td

index 2b928727f37a3a6da200ee6f8c415629b1182b77..03a0b0c3aedd60e7f3b8b38c8696d135afe87e75 100644 (file)
@@ -482,9 +482,9 @@ def X86_COND_P   : PatLeaf<(i8 14)>; // alt. COND_PE
 def X86_COND_S   : PatLeaf<(i8 15)>;
 
 let FastIselShouldIgnore = 1 in { // FastIsel should ignore all simm8 instrs.
-  def i16immSExt8  : ImmLeaf<i16, [{ return Imm == (char)Imm; }]>;
-  def i32immSExt8  : ImmLeaf<i32, [{ return Imm == (char)Imm; }]>;
-  def i64immSExt8  : ImmLeaf<i64, [{ return Imm == (char)Imm; }]>;
+  def i16immSExt8  : ImmLeaf<i16, [{ return Imm == (int8_t)Imm; }]>;
+  def i32immSExt8  : ImmLeaf<i32, [{ return Imm == (int8_t)Imm; }]>;
+  def i64immSExt8  : ImmLeaf<i64, [{ return Imm == (int8_t)Imm; }]>;
 }
 
 def i64immSExt32 : ImmLeaf<i64, [{ return Imm == (int32_t)Imm; }]>;