Fixing compiler handling of parens around boolean comparisons.
diff --git a/jinja2/compiler.py b/jinja2/compiler.py
index 5135a77..c0eb240 100644
--- a/jinja2/compiler.py
+++ b/jinja2/compiler.py
@@ -1529,9 +1529,11 @@
 
     @optimizeconst
     def visit_Compare(self, node, frame):
+        self.write('(')
         self.visit(node.expr, frame)
         for op in node.ops:
             self.visit(op, frame)
+        self.write(')')
 
     def visit_Operand(self, node, frame):
         self.write(' %s ' % operators[node.op])
diff --git a/tests/test_lexnparse.py b/tests/test_lexnparse.py
index a61c146..5c4c273 100644
--- a/tests/test_lexnparse.py
+++ b/tests/test_lexnparse.py
@@ -332,6 +332,12 @@
                                '{{ 2 == 2 }}|{{ 1 <= 1 }}')
         assert tmpl.render() == 'True|True|True|True|True'
 
+    def test_compare_parens(self, env):
+        tmpl = env.from_string(
+            "{{ i*(j<5) }}"
+        )
+        assert tmpl.render(i=2, j=3) == '2'
+
     def test_inop(self, env):
         tmpl = env.from_string('{{ 1 in [1, 2, 3] }}|{{ 1 not in [1, 2, 3] }}')
         assert tmpl.render() == 'True|False'