1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2; RUN: opt < %s -mtriple i686-unknown-unknown -codegenprepare -S | FileCheck %s 3 4target datalayout = "e-p:8:8" 5 6; The shl has UB (shift count oob). This used to result in undefined behavior 7; in codegenprepare when AddressingModeMatcher::matchOperationAddr tried to 8; shift a variable by that amount during compilation. Intent with the test 9; case is to verify that this compiles without complaints even if opt is built 10; with ubsan enabled. 11define dso_local void @main(i32 %a, ptr %p) { 12; CHECK-LABEL: @main( 13; CHECK-NEXT: [[SHL:%.*]] = shl i32 [[A:%.*]], -1229216766 14; CHECK-NEXT: [[ARRAYIDX926:%.*]] = getelementptr inbounds [3 x ptr], ptr [[P:%.*]], i32 0, i32 [[SHL]] 15; CHECK-NEXT: [[L0:%.*]] = load ptr, ptr [[ARRAYIDX926]], align 1 16; CHECK-NEXT: ret void 17; 18 %shl = shl i32 %a, -1229216766 19 %arrayidx926 = getelementptr inbounds [3 x ptr], ptr %p, i32 0, i32 %shl 20 %l0 = load ptr, ptr %arrayidx926, align 1 21 ret void 22} 23