Add a comment describing why transforming (shl x, 1) to (add x, x) is to be
authorDan Gohman <gohman@apple.com>
Thu, 16 Jun 2011 15:55:48 +0000 (15:55 +0000)
committerDan Gohman <gohman@apple.com>
Thu, 16 Jun 2011 15:55:48 +0000 (15:55 +0000)
considered safe enough in this context.

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

lib/Target/X86/X86InstrCompiler.td

index 33534cd82bdb143fb3c54ec56a995df53ac45958..adcc747eb4b88298bbf417507ed55aef9dd55d25 100644 (file)
@@ -1368,6 +1368,11 @@ def : Pat<(store (i8 (trunc_su (srl_su GR16:$src, (i8 8)))), addr:$dst),
 
 
 // (shl x, 1) ==> (add x, x)
+// Note that if x is undef (immediate or otherwise), we could theoretically
+// end up with the two uses of x getting different values, producing a result
+// where the least significant bit is not 0. However, the probability of this
+// happening is considered low enough that this is officially not a
+// "real problem".
 def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr  GR8 :$src1, GR8 :$src1)>;
 def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
 def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;