if_icmple 0xa4

Pops two ints; jumps if the first is less than or equal to the second.

Opcode
0xa4 (164)
Family
Branches and switches
Operands
  • 2 bytes: signed branch offset
Length
3 bytes
Operand stack
…, value1 (int), value2 (int) → …
Can throw
nothing at run time (beyond linking errors)
Spec name
if_icmp<cond>

What it does

Pops two ints and jumps if the first is <= the second.

As with every branch, javac tends to emit the opposite of the source condition and jump past the body. A loop such as for (int i = 0; i < n; i++) tests if_icmpge at the top to leave the loop, and ends with a goto back to the test.

How often javac uses it

In JDK 25.0.5's java.base module, if_icmple appears 2,267 times in 725 of its 7,391 classes: 0.12% of all instructions, the 83rd most common of 194 opcodes in use. Some of the methods that use it: java.io.BufferedInputStream.fill, java.io.BufferedOutputStream.growIfNeeded, java.io.BufferedWriter.growIfNeeded, java.io.ByteArrayInputStream.read.

Example

From the sample classes, compiled by javac 25 with -g. Each Java line is shown above the bytecode it compiled to; if_icmple is highlighted.

static int check(int n) in Constants, compiled by javac 25
9if (n > LIMIT) {
0iload_0 // n
1sipush 1000
10System.out.println(NAME + " exceeded");
7getstatic #9// System.out : PrintStream
10ldc #15// "limit exceeded"
12invokevirtual #17// PrintStream.println(String) : void
11return COMPUTED;
15getstatic #23// Constants.COMPUTED : int
13return (int) (BIG >> 38);

Open in the viewer

Related instructions

if_icmpgt Pops two ints; jumps if the first is greater than the second.ifle Pops an int; jumps if it is less than or equal to zero.goto Jumps unconditionally.

Specification: JVMS §6.5, if_icmp<cond> (Java SE 25).