-
Notifications
You must be signed in to change notification settings - Fork 14.5k
Closed
Labels
llvm:instcombineCovers the InstCombine, InstSimplify and AggressiveInstCombine passesCovers the InstCombine, InstSimplify and AggressiveInstCombine passesmiscompilation
Description
https://alive2.llvm.org/ce/z/w-iYiR
so if we compile this function:
define i32 @t1_ult_slt_0(i32 %x, i32 %replacement_low, i32 %replacement_high) {
%t0 = icmp slt i32 %x, 0
%t1 = select i1 %t0, i32 %replacement_low, i32 %replacement_high
%t2 = icmp ult i32 %x, 65536
%1 = xor i1 %t2, true
%r = select i1 %1, i32 %x, i32 %t1
ret i32 %r
}
alongside this test driver:
#include <stdio.h>
unsigned t1_ult_slt_0(unsigned a, unsigned b, unsigned c);
int main(void) {
printf("%u\n", t1_ult_slt_0(2, 0, 1));
}
the output is 1
optimizing the function using instcombine we get this:
regehr@john-home:~/Downloads$ opt -instcombine foo.ll -S -o -
; ModuleID = 'foo.ll'
source_filename = "foo.ll"
define i32 @t1_ult_slt_0(i32 %x, i32 %replacement_low, i32 %replacement_high) {
%1 = icmp slt i32 %x, 0
%2 = icmp sgt i32 %x, 65535
%3 = select i1 %1, i32 %replacement_low, i32 %x
%4 = select i1 %2, i32 %replacement_high, i32 %3
ret i32 %4
}
regehr@john-home:~/Downloads$
compiling the optimized function, using the same test driver, results in 2
being printed
found by @Hatsunespica's test generater + Alive2
cc @nunoplopes
Metadata
Metadata
Assignees
Labels
llvm:instcombineCovers the InstCombine, InstSimplify and AggressiveInstCombine passesCovers the InstCombine, InstSimplify and AggressiveInstCombine passesmiscompilation