Index: lib/Target/X86/AsmParser/X86AsmParser.cpp =================================================================== --- lib/Target/X86/AsmParser/X86AsmParser.cpp +++ lib/Target/X86/AsmParser/X86AsmParser.cpp @@ -1985,9 +1985,12 @@ // memory operand consumed. } else { SMLoc ExprEnd; + getLexer().UnLex(AsmToken(AsmToken::LParen, "(")); - // It must be an parenthesized expression, parse it now. - if (getParser().parseParenExpression(Disp, ExprEnd)) + // It must be either an parenthesized expression, or an expression that + // begins from a parenthesized expression, parse it now. Example: (1+2) or + // (1+2)+3 + if (getParser().parseExpression(Disp, ExprEnd)) return nullptr; // After parsing the base expression we could either have a parenthesized Index: test/MC/X86/x86_64-encoding.s =================================================================== --- test/MC/X86/x86_64-encoding.s +++ test/MC/X86/x86_64-encoding.s @@ -251,3 +251,15 @@ // CHECK: pinsrw $3, %ecx, %xmm5 // CHECK: encoding: [0x66,0x0f,0xc4,0xe9,0x03] pinsrw $3, %rcx, %xmm5 + +//CHECK movq 12(%rdi), %rsi +//CHECK encoding: [0x48,0x8b,0x77,0x0c] + movq 16+0-4(%rdi),%rsi + +//CHECK movq 12(%rdi), %rsi +//CHECK encoding: [0x48,0x8b,0x77,0x0c] + movq (16+(0-4))(%rdi),%rsi + +//CHECK movq 12(%rdi), %rsi +//CHECK encoding: [0x48,0x8b,0x77,0x0c] + movq (16+0)-1+1-2+2-3+3-4+4-5+5-6+6-(4)(%rdi),%rsi